[英]Why does ant think I have an old version of Java?
I am trying to build Groovy from source (on RH Linux) using ant, but for some reason it thinks that my Java version is 1.4, and not 1.6, and thus it won't compile.我正在尝试使用 ant 从源代码(在 RH Linux 上)构建 Groovy,但由于某种原因,它认为我的 Java 版本是 1.4,因此无法编译, The offending lines seem to be有问题的线似乎是
<condition property="groovy.build.vm5">
<not>
<contains string="${ant.java.version}" substring="1.4"/>
</not>
</condition>
in build.xml.在 build.xml 中。
When I type javac -version on the command line, it displays "javac 1.6.0_11".当我在命令行上键入 javac -version 时,它显示“javac 1.6.0_11”。 Any ideas?有任何想法吗?
Check the value of the environment variables JDK_HOME and JAVA_HOME.检查环境变量 JDK_HOME 和 JAVA_HOME 的值。
EDIT: "which java" will tell you which Java you're getting when you run java from the command line.编辑:当你从命令行运行 java 时,“which java”会告诉你你得到了哪个 Java。 If this tells you, for example, that you're getting "/usr/lib/jvm/java-6-sun/bin/java", you can set "JAVA_HOME" to "/usr/lib/jvm/java-6-sun"例如,如果这告诉您,您正在获取“/usr/lib/jvm/java-6-sun/bin/java”,您可以将“JAVA_HOME”设置为“/usr/lib/jvm/java-6 -太阳”
The answer of Jon Bright hints in a good direction: Possibly your installation of ant uses another java-version than the one you access via 'java -version'. Jon Bright 的回答暗示了一个好的方向:可能您安装的 ant 使用了另一个 java 版本,而不是您通过“java -version”访问的那个。 This is influenced by the environment-variables JDK_HOME and JAVA_HOME.这受环境变量 JDK_HOME 和 JAVA_HOME 的影响。
EDIT: If these variables are not present, then ant should find the Java from the installation that called ant.编辑:如果这些变量不存在,那么 ant 应该从名为 ant 的安装中找到 Java。 But if you set these variables, ant will pick these.但是如果你设置了这些变量,ant 会选择这些。 So setting this variables to the installation of JDK1.6 should be worth a try.所以设置这个变量来安装JDK1.6应该值得一试。 On Linux your Java could be on a subdirectory of /usr/lib/jvm.在 Linux 上,您的 Java 可能位于 /usr/lib/jvm 的子目录中。
I would check PATH environment variable.我会检查 PATH 环境变量。
What do you get when you on a clean shell (recently started) execute:当你在干净的 shell (最近开始)上执行时,你会得到什么:
$ java -version $ java-版本
Ant probably thinks you are trying to user OpenJDK's JVM and compiler (I think it comes installed with RH). Ant 可能认为您正在尝试使用 OpenJDK 的 JVM 和编译器(我认为它与 RH 一起安装)。 Try uninstalling that too.尝试卸载它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.