简体   繁体   中英

Ant with IntelliJ IDEA encoding problems

I'm using IntelliJ IDEA with Ant on Windows 10 to compile & run my project using build.xml

  • All my files (even build.xml) are coded in UTF-8

文件是UTF

  • I'm using UTF-8 in XML specification & javac command

    <?xml version="1.0" encoding="UTF-8"? >
    <javac target="1.8" srcdir="${test}" destdir="${build}" encoding="UTF-8" includeantruntime="false" >

  • I have set UTF-8 as default encoding in IDE

IDE中的默认编码

Still not working. It writes diamonds with question marks when there are some diacritics on output.

May it be something related to that I'm making JAR file which is then executed?

The solution is to add jvm argument within build.xml file.

Example:

<target name="execute" description="Launch an app" depends="jar">
    <java jar="${dist}/${jarname}" dir="${dist}" fork="true">
        <jvmarg value="-Dfile.encoding=UTF-8"/>
    </java>
</target>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM