On a Windows system, assuming you have multiple JREs installed there and assuming you launch java by explicitly specifying the absolute path of java.exe, and assuming you are not relying on any environment variables such as JAVA_HOME will java.exe pick up its runtime from the directory tree under which it is located or will it rely on some registry setting that the “official” java installer created?
In other words, what is the algorithm that Java uses to find its runtime? You do not have to specify the runtime on the classpath and if you attempt to output the contents of System.getProperty(“java.class.path”), the runtime is not shown.
If you invoke
C:\Some\Path\Java\jre\bin\java.exe, then it will useC:\Some\Path\Java\jre\lib\rt.jar. It basically uses..\lib\rt.jar. It doesn’t do any fancy resolution or registry lookups, just a relative path reference.If you need to find that reference from within a Java application, you can use: