Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find jvm from Java

How can I find a JVM ( java command, e.g. /usr/bin/java for mac and C:\Program Files\Java\bin\java.exe for Windows) from a Java application?

Reason: I am running an JNLP application that should download and launch other jar. I cannot just load the other jar because it has native libraries which could not be launched as JNLP.

like image 650
Johnny Everson Avatar asked May 20 '26 11:05

Johnny Everson


1 Answers

You could figure this out by using the java.home system property, which returns the path to the currently running jvm.

System.getProperty("java.home");

To be truly platform independent, you'd need to combine this with some platform detection to decide whether to append "bin/java" or "bin\java.exe", but it should be reasonably straightforward to do using some of the other system properties.

like image 181
Sean Reilly Avatar answered May 22 '26 00:05

Sean Reilly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!