Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current jre's file path

Tags:

java

filepath

Suppose we have two java applications A and B. Application A will call application B. Application A has started, however when A calls B, I don't know the java_home or any other jre path, I want to get which jre application A is run on, return the jre's execution file's path, is this possible?

like image 302
Xilang Avatar asked May 05 '26 11:05

Xilang


1 Answers

You can get the installation directory for the JRE by requesting the system propertie java.home:

String jrePath = System.getProperty("java.home");

More on System Properties here.

like image 58
Pit Avatar answered May 08 '26 03:05

Pit



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!