5

I have multiple JREs installed (6,7,8 both 32 and 64 bit). The way I have set things up is that I have the set up a number of JAVA_x_HOME paths and then reference JAVA_HOME=%JAVA_x_HOME% depending on wich version I want to use. However im not sure every application uses JAVA_HOME when deciding wich JRE to execute on.

Therfore my questions are:

Is there is a way to check wich JRE is used for running some started Java program under Windows 7?

What are the way an application can detect wich JRE to execute on?

1

4 Answers 4

1

Use System.getProperty("java.version");

It will return the jvm's version your code is running on. For example 1.8.0_25.

With System.getProperty("java.runtime.version"); you will get the runtime version, e.g. 1.8.0_25-b18

1

With System.getProperty("java.home"); you can find the installation directory for JRE the VM is running.

You can also get the "java.version" if you prefer.

Here's the reference for other System Properties that may be helpful.

1

So I found the easiest way to do this is to open task manager and right click the task i want to inspect. Right click and select go to process. After this I can select Properties and then the Details tab. This will show me the version of Java used for this process.

0

Go to cmd and run this command. This command will tell you java home set as on environment..

java -version  //for windows 

java -v // for linux

Not the answer you're looking for? Browse other questions tagged or ask your own question.