1

Does anyone have an idea on how to call something from JDK_INSTALL_FIR/bin using:

Runtime.getRuntime().exec(cmd)

Without having to care about OS terminal specifics like escaping or quoting spaces in paths on Windows or concatenating .exe at the end of the command.

In other words I want to make this work on Windows:

Runtime.getRuntime().exec("C:\Program Files (x86)\Java\jdk1.7.0_45\bin\java -version")

I'm open to any solutions like bundling my own JDK, or generally anything that will save me from checking what OS I'm currently running on.

Thanks.

Simeon
  • 7,582
  • 15
  • 64
  • 101

1 Answers1

0

Java path is saved in system variables (mostly)
try something like:

System.out.println(System.getenv("JAVA_HOME"));

Which should return path to java (not sure about "JAVA-HOME" )
It is from:
How can I get System variable value in Java?


Generally I advice using:
System.getenv(String);

method:
getenv documentation

Community
  • 1
  • 1
maskacovnik
  • 3,080
  • 5
  • 20
  • 26