owan
owan

Reputation: 341

Get path to java JRE

It it possible to get the location of the jre that is used for the current process. Need to launch an other java application as a separate process. Having different jre's available (and no path variable set) I would like ask eg. the loader for this. Running on Solaris, Linux, Windows.

Upvotes: 34

Views: 29587

Answers (3)

Theepan Gnani
Theepan Gnani

Reputation: 11

System.out.println(System.getProperty("java.home"));

The code above will return the full physical path to current jvm's jre path. Tested only in Windows 10.

Upvotes: 1

user467871
user467871

Reputation:

System.getProperty("java.home")

Upvotes: 10

Hendrik Brummermann
Hendrik Brummermann

Reputation: 8312

You can use:

System.getProperty("java.home")

http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties%28%29 says:

java.home: Java installation directory

Upvotes: 47

Related Questions