0

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...

Community
  • 1
  • 1
Voldemort
  • 17,552
  • 47
  • 139
  • 262
  • http://stackoverflow.com/questions/6493856/how-to-programatically-get-all-java-jvm-installed-not-default-one-using-java – Nielarshi Mar 07 '15 at 20:17

1 Answers1

1

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

yole
  • 87,251
  • 17
  • 245
  • 186