本文介绍了哪里蚂蚁设置其“java.home”(而且是错了),并且它应该追加“/ JRE”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我使用Ant版本1.7.1(默认安装)在CentOS 6.3:

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 设置和我跑蚂蚁

[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

所以,我得到一件事情 - 显然的是错误的(骇然!)它描述了 java.home 系统属性的Java安装目录。我知道,因为描述 java.home 系统属性为用于Java运行时环境(JRE)的安装目录。在在JVM系统属性中的环境不一定等于 java.home 换言之, 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?!)

问:在哪里以及如何做蚂蚁的get / set系统属性 java.home

QUESTION: Where and how does Ant get/set the system property java.home?

推荐答案

真是一个JVM内部问题

由于蚂蚁正好呼应java.lang.System的属性(请参阅下原帖评论以上),这实在是一个JVM的问题。该是核心间preTER。 code是在可在网上。

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对于热点(os_linux.cpp)的C ++ code线309 是有一个 init_system_properties_values​​()方法在操作系统类。它做了一些轻微的启发式那种嗅出名为 home_path 一个变量,它最终被设置为Java的什么用户看到的java.home的位置。在code注释表明,'<&JAVA_HOME GT; / JRE被正式指定为java.home(在JDK的情况下安装)在java.lang.System的属性值。

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).

这篇关于哪里蚂蚁设置其“java.home”(而且是错了),并且它应该追加“/ JRE”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:53