I have this simple java command line application
public static void main(String[] args) throws IOException {
System.out.println("Hello World !");
System.in.read();
}
When I start it on Windows 10, Windows Task Manager displays two instances of java.exe as subprocesses of the Windows Command Prompt process:
C:\Program Files\Common Files\Oracle\Java\javapath_target_383000\java.exe
C:\Program Files\Java\jdk-15.0.1\bin\java.exe

One should think one instance of the JVM should be enough to run this program, so why are there two ?
Edit: I compiled this program against a JDK 1.8.0 (instead of JDK 15.0.1) and now only the Java(TM) Platform SE binary shows up.
This is a feature of Oracle's installer for Java on Windows. The installer adds the folder C:\Program Files\Common Files\Oracle\Java\javapath_target to the PATH variable. This folder contains a symlink to a java.exe executable in another folder. This executable detects the location of the latest/configured JRE version by checking the registry and JAVA_HOME. Then it calls java.exe of the actual JRE. So the first java.exe is not a real JVM but a simple native app that gets executed, when you call java within the console. To avoid the usage of this mechanism simply replace the javapath_target folder with the folder of your JRE within the PATH environment variable. For a more detailed description see also this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With