Ant在哪里设置它的'java.home'(并且它是错误的),它应该附加'/ jre'? [英] Where does Ant set its 'java.home' (and is it wrong) and is it supposed to append '/jre'?
问题描述
好的,我在CentOS 6.3上使用Ant版本1.7.1(默认安装):
Okay, I'm using Ant version 1.7.1 (default install) on CentOS 6.3:
[theuser@dev-ingyhere ~]$ ant -version
Apache Ant version 1.7.1 compiled on August 24 2010
[theuser@dev-ingyhere ~]$ cat /etc/*-release
CentOS release 6.3 (Final)
我有 JAVA_HOME
我运行 ant
:
[theuser@dev-ingyhere ~]$ export JAVA_HOME=/usr/java/jdk1.7.0_17 ; echo $JAVA_HOME ;
/usr/java/jdk1.7.0_17
[theuser@dev-ingyhere ~]$ ant -diagnostics | grep java\\.home
java.home : /usr/java/jdk1.7.0_17/jre
这更有趣:
[theuser@dev-ingyhere ~]$ export JAVA_HOME=/a/fools/folly ; echo $JAVA_HOME ; ant -diagnostics | grep java\\.home
/a/fools/folly
java.home : /usr/java/jdk1.7.0_17/jre
[theuser@dev-ingyhere ~]$ env | grep JAVA
JAVA_HOME=/a/fools/folly
所以,我得到一件事 - 显然是 Oracle的Java 7 Javadoc for Class系统是错误的(aghast!),它将 java.home
System Property描述为Java安装目录。我知道,因为 Java(TM)系统属性教程将 java.home
System Property描述为Java运行时环境(JRE)的安装目录。换句话说,环境中的 JAVA_HOME
在JVM系统属性中并不一定等于 java.home
。 (什么设置?!)
So, I do get one thing -- apparently Oracle's Java 7 Javadoc for Class System is WRONG (aghast!) where it describes the java.home
System Property as the "Java installation directory." I know that because the Java(TM) Tutorials for System Properties describes the java.home
System Property as the "Installation directory for Java Runtime Environment (JRE)." In other words the JAVA_HOME
in the environment does not necessarily equal java.home
in the JVM System Properties. (What sets that?!)
问题: Ant / / c $ c>属性 java.home
?
QUESTION: Where and how does Ant
get/set the system property java.home
?
推荐答案
真的是一个JVM内部问题
由于Ant只是回显java.lang.System属性(见原来的帖子上面的注释),这实际上是一个JVM题。核心解释器是 Java HotSpot Virtual Machine 。代码可通过 hg.openjdk.java.net 在线获取。
Since Ant is just echoing the java.lang.System properties (see comment above under original post), this is really a JVM question. The Java HotSpot Virtual Machine is the core interpreter. Code is available online at hg.openjdk.java.net.
On line 309 of the C++ code for HotSpot (os_linux.cpp) there is a an init_system_properties_values()
method in the os
class. It does some mild heuristics to kind of sniff out the location for a variable named home_path
which ends up being set to what Java users see as "java.home". Comments in the code indicate that '<java_home>/jre' is being formally specified as the java.lang.System property value for "java.home" (in the case of a JDK install).
这篇关于Ant在哪里设置它的'java.home'(并且它是错误的),它应该附加'/ jre'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!