JDK 7将自身报告为JRE(通过“java.home”系统属性) [英] JDK 7 reports itself as a JRE (via "java.home" system property)

查看:149
本文介绍了JDK 7将自身报告为JRE(通过“java.home”系统属性)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚安装了最新的JDK 7 Update 21并编写了以下单行程序(在Windows 7上):

I just installed the latest JDK 7 Update 21 and wrote the following one-liner (on Windows 7):

public static void main(String[] args) {
    System.out.println("java.home = " + System.getProperty("java.home"));
}

输出(令人惊讶):

java.home = D:\Java\jdk1.7.0_21\jre

我相信我修正了所有常见原因:

I believe I fixed all the common causes:


  1. JAVA_HOME设置为D: \ Java \ _jdk1.7.0_21

  2. 我已将D:\ Java \ _jdk1.7.0_21 \ bin设置为系统路径设置中的第一个路径。

  3. Windows \ System32中没有java.exe

  4. 我正在使用新鲜命令行

  5. 我已广泛搜索此网站和其他网站

  6. 我的注册表中没有HKEY_LOCAL_MACHINE \ SOFTWARE \ JavaSoft \ Java运行时环境键。 HKEY_LOCAL_MACHINE \SOFTWARE \ JavaSoft \ Java Development Kit \1.7的值包含正确的JavaHome值。

  7. 将-server选项添加到java.exe电话不会改变输出

  1. JAVA_HOME is set to "D:\Java\jdk1.7.0_21"
  2. I have set "D:\Java\jdk1.7.0_21\bin" as the first path in the system PATH setting.
  3. There is no java.exe in Windows\System32
  4. I am using a "fresh" command-line
  5. I have searched this and other sites extensively
  6. My registry does not contain a "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" key. The value of "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.7" contains a correct "JavaHome" value.
  7. Adding "-server" option to the java.exe call does not change the output

以下是您的信息的更多输出

Here is some more output for your information

D:\Temp>echo %PATH%
d:\Java\jdk1.7.0_21\bin

D:\Temp>echo %JAVA_HOME%
D:\Java\jdk1.7.0_21

D:\Temp>type SystemInfo.java
public class SystemInfo {

        public static void main(String[] args) {
                System.out.println("java.home = " + System.getProperty("java.home"));
        }

}

D:\Temp>java -verbose SystemInfo
[Opened d:\Java\jdk1.7.0_21\jre\lib\rt.jar]
[Loaded java.lang.Object from d:\Java\jdk1.7.0_21\jre\lib\rt.jar]
[Loaded java.io.Serializable from d:\Java\jdk1.7.0_21\jre\lib\rt.jar]
...
[Loaded java.lang.Void from d:\Java\jdk1.7.0_21\jre\lib\rt.jar]
java.home = d:\Java\jdk1.7.0_21\jre
[Loaded java.lang.Shutdown from d:\Java\jdk1.7.0_21\jre\lib\rt.jar]
[Loaded java.lang.Shutdown$Lock from d:\Java\jdk1.7.0_21\jre\lib\rt.jar]

(更新:) 基本上我需要知道,如何运行我的java应用程序,以便它可以访问java编译器(在JDK的tools.jar中找到),而无需将JAR复制到其他地方。

BTW背后的主要问题s是我的码头无法编译JSP,因为缺少java编译器。我知道我可以将tools.jar添加到JRE \lib; \\ _ext,但那不是长期解决方案。

BTW the main problem behind this is that my jetty can't compile a JSP since the java-compiler is missing. I know I can add "tools.jar" to JRE\lib\ext but thats not a long-term solution.

推荐答案

默认情况下 - 在Java HotSpot解释器的C ++代码中指定。此外,Sun最初希望系统属性在环境的Java主目录指向JDK时设置。

This is by default -- specified in the C++ code of the Java HotSpot interpreter. Also, it is what Sun originally wanted the System Property to set when the environment's Java home points to a JDK.

请参阅 Java(TM)系统属性教程,它将java.home系统属性描述为Java运行时环境(JRE)的安装目录。另请注意, Oracle的Java 7类系统的Javadoc 是错误的(骇然!),它将java.home系统属性描述为Java安装目录。

See the Java(TM) Tutorials for System Properties where it describes the java.home System Property as the "Installation directory for Java Runtime Environment (JRE)." Also, note that Oracle's Java 7 Javadoc for Class System is WRONG (aghast!) where it describes the java.home System Property as the "Java installation directory."

答案取决于实际JVM代码的第309行

这篇关于JDK 7将自身报告为JRE(通过“java.home”系统属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆