java 如何在ant build xml中设置java_home
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4785708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set java_home in ant build xml
提问by CodeRocker
I need to run my project on java 1.4 and
pmd and findbugs on java 1.5
So, i need to set java_home in my build xml.
我需要在 java 1.4 和
pmd上运行我的项目,在 java 1.5上运行findbugs
所以,我需要在我的构建 xml 中设置 java_home。
Thanks in advance,
-Sravan
提前致谢,
-Sravan
回答by RicoZ
There is a attribute called "jvm" for the java-task:
java-task 有一个名为“jvm”的属性:
<java jvm="PATH_TO_YOUR_VM" fork="true"...>
...
</java>
回答by mstrok
Alternatively, if you are in Windows, you could create 2 batch files: one that sets JAVA_HOME to 1.3 followed by your call to ant, a second one that sets JAVA_HOME to 1.4 followed by your call to ant. ex:
或者,如果您使用的是 Windows,您可以创建 2 个批处理文件:一个将 JAVA_HOME 设置为 1.3,然后调用 ant,另一个将 JAVA_HOME 设置为 1.4,然后调用 ant。前任:
startAnt1.3.bat:
startAnt1.3.bat:
SET JAVA_HOME=C:\Java1.3\etc.
ant myTarget
startAnd1.4.bat:
startAnd1.4.bat:
SET JAVA_HOME=C:\Java1.4\etc.
ant myTarget