The JDK itself does not use the windows registry to run.
It is the JRE that uses the system registry to run in some situations like an Applet or a program started with the WebStart technolgy.
Finally, the JRE will only use the registry if it is run from the Windows system directory (ex . C:/winnt/system32/java.exe). This would happen if the user just types "java" on the commandline in some random directory, because the system directory is always in the user's path. In this situation, the java.exe will locate the current Java installation by looking at the registry key
[HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime EnvironmentCurrentVersion]
and then get the path of the JRE from the corresponding key
[HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment1.5JavaHome]
Beware that some software (eg. Oracle) installs themself at the beginning of the PATH definition, so it's their Java installation that will be found first.
You can run the absolute path to the java.exe file, as in
"C:Program FilesJavajre1.5.0injava.exe" MyClass
It will not use the registry, and it will be guaranteed to use jre1.5.0.
So for a regular Java SE program, it is safe to specify the complete path to the JRE to launch it.
But for the Applet/Plugin or WebStart-based programs, the registry is always used to determine the current JRE.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…