简体   繁体   中英

How to read an Environment variable from Java code

I have a properties file that needs to be loaded into a java program. Part of the path is defined by the system environment variable JAVA_TOP . When i give the full path it recognizes the file. Otherwise it won't. I tried giving file path as:

<JAVA_TOP>/abc.... 
$JAVA_TOP/abc...
JAVA_TOP/abc

None of them seem to work. Please let me know how to read the environment variable JAVA_TOP from the java application.

I am assuming, you are looking at reading the environment variable JAVA_TOP in your Java code. System.getenv("JAVA_TOP") should return the value of JAVA_TOP

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