Saturn
Saturn

Reputation: 18159

Getting the path to Java in a Java program

Was reading this question: Execute .jar file from a Java program and the answer tells you to use a ProcessBuilder:

ProcessBuilder pb = new ProcessBuilder("/path/to/java", "-jar", "your.jar");

How do I find out the /path/to/java using code? Of course I could look up java in my machine, but an end-user may not necessarily have Java installed in the same place as I do...

Upvotes: 0

Views: 55

Answers (1)

yole
yole

Reputation: 97338

Use System.getProperty("java.home").

Upvotes: 1

Related Questions