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:
- JAVA_HOME is set to "D:\Java\jdk1.7.0_21"
- I have set "D:\Java\jdk1.7.0_21\bin" as the first path in the system PATH setting.
- There is no java.exe in Windows\System32
- I am using a "fresh" command-line
- I have searched this and other sites extensively
- 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.
- 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.