• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4714
  • Last Modified:

Ant don't treat UTF-8 files as UTF-8 when compiling

I have a strange problem. I'm Swedish and we have special characters å ä ö in our alphabet.
In my project all my java-files are encoded as UTF-8. When I compile my project inside intellij my text-strings apperas correct in the console and in my swing-app.

However when I run my build script in Ant it creates strange characters instead of å ä ö.

If I put the text-strings in a propertiefile everything works well even with an ant-compile.

<property name="compile.debug" value="true"/>
    <property name="compile.deprecation" value="true"/>
    <property name="compile.optimize" value="true"/>
 
 
        <javac srcdir="${src.dir}" destdir="${build.home}"
               debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
            <classpath refid="libs"/>
            <classpath location="${build.home}"/>
            <include name="**/*.java"/>
            <exclude name="**/StartJetty6.java"/>
        </javac>

Open in new window

0
Geronimooo
Asked:
Geronimooo
  • 5
  • 4
1 Solution
 
objectsCommented:
> However when I run my build script in Ant it creates strange characters instead of å ä ö.

creates them where?

0
 
GeronimoooAuthor Commented:
Same as when I compile it in Intellij, in the console and in my swing-app when I run my app...
0
 
objectsCommented:
sounds like it just that the console (and/or the font it uses) that you are viewing it doesn't support utf8 swedish characters.

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
GeronimoooAuthor Commented:
Nope.... As I wrote.. if I compile the project inside intellij and then run it.. everything looks as it should..
compile the same project with ant does not give the same result...

In both cases I'm looking at text printed in my Swing-app.

Running the project inside intellij with ant-build generated class files will give the same problem. Recompiling inside intellij and everything works..
0
 
objectsCommented:
try:

ant -Dfile.encoding=UTF8 build
0
 
GeronimoooAuthor Commented:
tried that same problem...
downloaded ant 1.7.1 and tried as well..

0
 
objectsCommented:
no idea sorry, thats a weird one

0
 
GeronimoooAuthor Commented:
solved it. You could add UTF-8 at the compiler in ant.

See below code
        <javac srcdir="${src.dir}" destdir="${build.home}"
               debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" encoding="UTF-8">
            <classpath refid="libs"/>
            <classpath location="${build.home}"/>
            <include name="**/*.java"/>
            <exclude name="**/StartJetty6.java"/>
        </javac>

Open in new window

0
 
objectsCommented:
good work :)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now