Thomas Auinger
Thomas Auinger

Reputation: 2095

JDK 7 reports itself as a JRE (via "java.home" system property)

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"));
}

the output is (surprisingly):

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

I believe I fixed all the common causes:

  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]

(Updated:) Basically I need to know, how to run my java application so that it has access to the java-compiler (found in the JDK's tools.jar) without copying that JAR to some other place.

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.

Upvotes: 4

Views: 3143

Answers (2)

ingyhere
ingyhere

Reputation: 13861

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.

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

The answer lies on line 309 of the actual JVM code!

Upvotes: 7

Alexander Rühl
Alexander Rühl

Reputation: 6939

It's perfectly fine what you see as output - it's your default Java execution environment.

In order to configure jetty to use your JDK, maybe this helps.

Upvotes: 0

Related Questions