简体   繁体   English

蚂蚁构建-JAVA_HOME变量未更新

[英]Ant build - JAVA_HOME variable not getting updated

I am trying to run an ant build to generate a jar and i get the following error: 我试图运行一个蚂蚁生成以生成一个罐子,我得到以下错误:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/lib/tools.jar
Buildfile: /my/path/to/the/required.xml

make:
[javac] /my/path/to/the/required..xml:11: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

BUILD FAILED
/my/path/to/the/required.xml:11: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-1.8.0-openjdk-   1.8.0.91-0.b14.el7_2.x86_64/jre"

My questions: 1. I did a bit of reading online and i concluded its because i am pointing it to the JRE and not JDK which is why it failed. 我的问题:1.我做了一些在线阅读,并得出结论,因为我将其指向JRE,而不是JDK,这就是为什么它失败的原因。 Initially i did 最初我做了

export JAVA_HOME=readlink -f $(which java)

So i updated and exported my JAVA_HOME variable with output of which javac command. 所以我用which javac命令的输出更新和导出了JAVA_HOME变量。 What is interesting is that last part of the error did not display the changed JAVA_HOME value. 有趣的是,错误的最后一部分没有显示更改后的JAVA_HOME值。 Why is that? 这是为什么?

  1. What is this includeantruntime and how to get rid of it? 这是什么includeantruntime以及如何摆脱它? I use ant 1.9.2 我使用ant 1.9.2

You may want to check and update ant configuration file for the JAVA_HOME settings. 您可能需要检查并更新JAVA_HOME设置的ant配置文件。 It is possible that the value for $JAVA_HOME set for your shell in .bashrc can be overridden in the files /etc/ant.conf, $HOME/.ant/ant.conf, and $HOME/.antrc. 可能会在文件/etc/ant.conf、$HOME/.ant/ant.conf和$ HOME / .antrc中覆盖为.bashrc中的shell设置的$ JAVA_HOME值。 If you execute bash -x it will print debugging information which should help you track down where $JAVA_HOME is being overridden. 如果执行bash -x,它将打印调试信息,这将有助于您跟踪$ JAVA_HOME被覆盖的位置。

Perhaps its just a matter of where Ant first looks for the java executable (ie in the JAVA_HOME variable or somewhere else). 也许这只是Ant首先在哪里寻找Java可执行文件的问题(即,在JAVA_HOME变量或其他位置)。

You can test if this is the case by setting the fork="true" and the executable parameter as described here: https://ant.apache.org/manual/Tasks/javac.html and see if this is the case. 您可以通过设置fork="true"executable参数(如下所述)来测试是否存在这种情况: https : //ant.apache.org/manual/Tasks/javac.html并查看是否存在这种情况。

Also, did you actually found the tools.jar in the JVM you're currently pointing your JAVA_HOME at ? 另外,您是否确实在当前将JAVA_HOME指向的JVM中找到了tools.jar?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM