传递“-J-Duser.language"通过ant进入javac,确保编译错误以正确的语言报告 [英] Passing "-J-Duser.language" into javac through ant to ensure compilation errors are reported in the correct language

查看:24
本文介绍了传递“-J-Duser.language"通过ant进入javac,确保编译错误以正确的语言报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电脑目前设置为日语以进行测试.如果我的 java 项目有编译错误,则消息会以日语报告.

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.

例如将 1 个源文件编译到 [...目录...][...class...].java:172: シンボルの见つけられません.

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

我更愿意看到英文错误.

I would prefer to see the errors in english.

不使用 ant 的解决方法是使用javac -J-Duser.language=en [..java 文件...]这使得 javac 给出英文错误消息(-J 告诉 javac 将其余的参数传递给 java)

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)

我的问题是:我如何将它传递给 ant

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

推荐答案

尝试将 添加到您的 调用中.例如:

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 修正了 arg 值.此外,这仅在编译器分叉时才有效;我更新了示例以反映这一点.

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

这篇关于传递“-J-Duser.language"通过ant进入javac,确保编译错误以正确的语言报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆