简体   繁体   中英

how to get java home in Linux?

Inside a Java program, how can I read the JAVA_HOME variable (to be sure it is set the correct way)? Similarly, how can I get the path of the bin folder? That is, the path usually set in Windows via:

path %path%;%JAVA_HOME%\\bin

JAVA_HOME and PATH are environment variables. So you can get values like this :

String javaHome = System.getenv("JAVA_HOME");
String path = System.getenv("PATH");

Please follow below link for this :

http://stackoverflow.com/questions/16297326/checking-getting-java-home-variable-from-java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM