如何在控制台参数中而不是在 Eclipse 中为 ANT 设置 JRE

如何在控制台参数中而不是在 Eclipse 中为 ANT 设置 JRE

问题描述:

我的问题是一样的,但我不知道如何在 ant 中正确设置另一个 JRE!我需要在控制台中运行脚本,例如path-to-buil-xml/ant"

My question is the same, but I do not know how to set another JRE right in ant! I need to run scripts in console like "path-to-buil-xml/ant"

我在 Eclipse 中这样做并选择了我需要的 JRE,但是如何在控制台 ant 中设置它?
参数名称是什么?

I do that in Eclipse and I select JRE that I need, but how to set it in console ant?
What the name of parameter?

eclipse:更改用于运行 ant 的 jre

我需要在没有 Eclipse 的情况下构建我的项目.

I need to build my project in the conditions when I do not have Eclipse.

  1. 现在,当我将 JRE 从 C:\Program Files\Java\jdk1.6.0_27 更改为另一个 JRE 1.4 时,我可以使用 Eclipse 编译项目.
  2. 我可以在没有 Eclipse 的情况下做同样的事情,但将 JAVA_HOME 更改为 JRE 1.4.但是在目标机器上我无法更改 JAVA_HOME,因为访问被拒绝!

怎么做?

在控制台中ant引用环境变量JAVA_HOME来查找JRE.

In the console ant refers to the environment variable JAVA_HOME to find the JRE.

如果您不想编辑 windows cmd 控制台的系统设置,请使用(这将在您关闭控制台时重置)

If you don't want to edit the system settings for the windows cmd console use (this will reset when you close the console)

SET JAVA_HOME=PATH_TO_JAVA_HOME

您还可以将 jdk(通过 javac coomand)设置为 javac 任务的参数:

You can also set the jdk(via the javac coomand) an argument to the javac task:

  <javac srcdir="${src}"
         destdir="${build}"
         fork="yes"
         executable="/opt/java/jdk1.1/bin/javac"
  />

旁注:

如果你需要编译,它真的需要是一个jdk.

Side note:

It really needs to be a jdk, if you need to compile.