JAVA2013. 6. 26. 17:41

 

[출처] System.getProperty(시스템 환경변수)|작성자 joypheonix

1. set

1) System.getProperty(key, defaultvalue.) 사용    : key 가 null 일때 defaultvalue값을 가져옴 

 ( 참고 : http://www.tutorialspoint.com/java/lang/system_getproperty_string_def.htm )

2) was(tomcat, jeus...)별로 <command-option>에

-Dkey값 = value값 설정

예) jeus

-->

<engine-container>
<name>container6</name>
<command-option>-Xms256m -Xmx512m
-Djplug.home=D:/eclipse_workspace/FFI/WebContent/jplugreport/license
</command-option>
<engine-command>
<type>servlet</type>
<name>engine6</name>
</engine-command>
</engine-container>

 예) JBOSS 서버 예

1) 이클립스 서버더블클릭

2) Open launch configuration 클릭

3) Arguments 에   -Dkey값 = value값 설정

 

 

2. get

// Get the value of the system property
String prop = System.getProperty("jplug.home);
// my value

3. 기본 저장 키

System.getProperty("java.version") : java.version=1.6.0_17

System.getProperty("java.home") : java.home=C:\jdk1.6.0_17\jre

System.getProperty("java.vendor") : java.vendor=Sun Microsystems Inc.

System.getProperty("java.specification.version") : java.specification.version=1.6

System.getProperty("os.name") : os.name=Windows 7

System.getProperty("os.arch") : os.arch=x86

System.getProperty("user.country") : user.country=KR

System.getProperty("user.name") : user.name=saint

System.getProperty("user.language") : user.language=ko

System.getProperty("file.encoding") : file.encoding=MS949

System.getProperty("file.separator") : file.separator=\

System.getProperty("path.separator") : path.separator=;

------------------------------------

Property 정보를 확인하는 자바 소스

------------------------------------

import java.util.Enumeration;
import java.util.Properties;

public class TestProperty {
public static void main(String[] args) {
Properties sysprops = System.getProperties();
for (Enumeration e = sysprops.propertyNames(); e.hasMoreElements();) {
String key = (String) e.nextElement();
String value = sysprops.getProperty(key);
System.out.println(key + "=" + value);
}
}
}

 

'JAVA' 카테고리의 다른 글

[Configuration] 설정  (0) 2013.07.01
Http 송수신 HttpClient  (0) 2013.06.28
for문 ":" 정리  (0) 2013.06.25
[펌]xpath 를 이용, java 에서 xml 문서 쉽게 파싱하기  (0) 2013.06.13
Log4j 로그 두번찍히는 문제  (0) 2013.06.05
Posted by 선한열심