반응형
OS / JVM 환경변구 값 읽어오기.
public static void main( String[] args ) {
System.out.println("OS 환경변수 값");
System.getenv().entrySet().forEach(e -> {
System.out.println("\t" + e.getKey() + "=" + e.getValue());
});
// export java_test_value="TEST VAL"
System.out.println("OS 환경변수 java_test_value 값 = " + System.getenv("java_test_value"));
System.out.println("");
System.out.println("JVM 환경변수 값");
Properties props = System.getProperties();
for(Enumeration en = props.propertyNames(); en.hasMoreElements();) {
String key = (String)en.nextElement();
String value = props.getProperty(key);
System.out.println("\t" + key + "=" + value);
}
System.out.println("JVM 환경변수 user.name값 = " + System.getProperty("user.name"));
System.out.println("JVM 환경변수 user.test값 = " + System.getProperty("user.test", "user.test property is null."));
}
반응형
'프로그래밍 > Java' 카테고리의 다른 글
[JAVA] java.lang.UnsatisfiedLinkError: no net in java.library.path (1) | 2021.06.25 |
---|---|
Too many open files (2) | 2021.06.14 |
[Spring Boot] log4jdbc 설정. (1) | 2020.01.16 |
Rabbit MQ 간단 사용. (0) | 2018.12.21 |
singleton 객체. (0) | 2018.12.06 |