But if the path is not set at the time of compiling, the JRE that is invoked by typing "java" at the command prompt is the JRE that was installed with the first JDK installed
How do you define the "first JDK installation" here? In general it's the first to appear in the path is picked. And you can check the version used by
java by typing
java -version. For this, of course
you should have set the path appropriately or be in the JDK/bin directory or use the exact path to the JDK/bin.