简体   繁体   English

为什么 ant 认为我有旧版本的 Java?

[英]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.

相关问题 为什么 java -version 返回旧版本? - Why does java -version return an old version? 为什么蚂蚁认为包裹不存在? - Why does ant think package doesn't exist? Java为什么认为我的对象是变量? - Why does Java think my object is a variable? 为什么Ant会为其目标Java版本编译具有未定义方法的Java源代码 - Why does Ant compile Java source that has undefined methods for its target Java version 使用ANT时,如果我有一些特定的java版本,我怎么才能定义任务? - When using ANT, how can I define a task only if I have some specific java version? Gradle 5和Java 11构建错误:为什么Gradle认为我使用的是Java 10? - Gradle 5 & Java 11 build error: Why does Gradle think I'm using Java 10? 为什么Netbeans Ant使用正确的jar进行编译,却使用旧的jar进行编译? - Why does Netbeans Ant compile with correct jar but builds with old jar? 为什么Java(在一个特定的安装上)认为我是自签名的? - Why does Java (on one particular installation) think I'm self-signing? 为什么 Java 8 Stream 接口没有 min() 无参数版本? - Why Java 8 Stream interface does not have min() no-parameter version? 我无法从Java运行python脚本,我认为这是因为该脚本没有执行权限 - I can't run a python script from java and I think it's because the script does not have execute permissions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM