Passing "-J-Duser.language" to javac via ant to ensure that compilation errors are reported in the correct language

My computer is currently configured as Japanese for testing. If my java project has a compilation error, the message is reported in Japanese.

eg. Compilation of 1 source file into the directory [......] [... class ...]. java: 172: シ ン ボ ル を 見 つ け ら れ ま せ ん.

I would rather see errors in English.

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

My question is: how do I pass this to ant [deleted to remove the parameters I tried so that it doesn't work]

+3
javac ant
source share
1 answer

Try adding <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 arg values. In addition, this only works if the compiler is forked; I updated this example to reflect this.

+4
source share

All Articles