?
Solved

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

Posted on 2009-02-12
9
Medium Priority
?
4,508 Views
Last Modified: 2013-11-10
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
Comment
Question by:Geronimooo
  • 5
  • 4
9 Comments
 
LVL 92

Expert Comment

by:objects
ID: 23620374
> However when I run my build script in Ant it creates strange characters instead of å ä ö.

creates them where?

0
 

Author Comment

by:Geronimooo
ID: 23620384
Same as when I compile it in Intellij, in the console and in my swing-app when I run my app...
0
 
LVL 92

Expert Comment

by:objects
ID: 23620395
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Geronimooo
ID: 23620403
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
 
LVL 92

Expert Comment

by:objects
ID: 23620418
try:

ant -Dfile.encoding=UTF8 build
0
 

Author Comment

by:Geronimooo
ID: 23620585
tried that same problem...
downloaded ant 1.7.1 and tried as well..

0
 
LVL 92

Expert Comment

by:objects
ID: 23620596
no idea sorry, thats a weird one

0
 

Accepted Solution

by:
Geronimooo earned 0 total points
ID: 23620651
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
 
LVL 92

Expert Comment

by:objects
ID: 23620664
good work :)

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month16 days, 18 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question