Is it possible to specify the JVM to use when you call ‘java jar jar_name.jar’ . I have two JVM installed on my machine. I can not change JAVA_HOME as it may break code that is all ready running.
Kind Regards
Stephen
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes – just explicitly provide the path to java.exe. For instance:
The easiest way to do this for a running command shell is something like:
For example, here’s a complete session showing my default JVM, then the change to the path, then the new one:
This won’t change programs which explicitly use JAVA_HOME though.
Note that if you get the wrong directory in the path – including one that doesn’t exist – you won’t get any errors, it will effectively just be ignored.