Passing “-J-Duser.language” into javac through ant to ensure compilation errors are reported in the correct language

最后都变了- 提交于 2020-01-10 05:25:06

问题


My PC is currently set up as Japanese for testing purposes. If my java project has a compilation error the message is reported in Japanese.

e.g. Compiling 1 source file to [...directory...] [...class...].java:172: シンボルを見つけられません。

I would prefer to see the errors in english.

Without using ant the fix for this is to use javac -J-Duser.language=en [..java files...] which makes javac give english error messages (the -J tells javac to pass the rest of the argument to java)

My question is: how do I pass this to ant [editted to remove options I tried that didn't work]


回答1:


Try adding a <compilerarg> to your <javac> call. For example:

<javac srcdir="${src.dir}" destdir="${classes.dir}" fork="true">
    <compilerarg value="-J-Duser.language=en"/>
    <compilerarg value="-J-Duser.country=GB"/>
</javac> 

EDIT Fixed the arg values. Also, this only works if the compiler is forked; I updated the example to reflect that.



来源:https://stackoverflow.com/questions/920763/passing-j-duser-language-into-javac-through-ant-to-ensure-compilation-errors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!