I have created a runnable jar with the following content in a MANIFEST file. This works fine when running the main class in eclipse and it is using JAVA_HOME that is set in my eclipse. I have also set the environment variable JAVA_HOME to my JDK installation path on my local. Now the problem is if run the same jar using below command, it is taking the different path instead of the JAVA_HOME environment variable.
I have tried running the below command from the command line but still did not work as expected
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_211 java -jar my-jar-name.jar
in my source code, I am using System.getProperty("java.home") which prints C:\Program Files\Java\jre1.8.0_211 .But I have set the JAVA_HOME to C:\Program Files\Java\jdk1.8.0_211 in environment variables. If I run the echo %JAVA_HOME% manually on the command line, it prints correctly.
I expect that my jar prints the JAVA_HOME as below. C:\Program Files\Java\jdk1.8.0_211 But printing the actually below. C:\Program Files\Java\jre1.8.0_211
There are no errors