我在测试前,添加了一个环境变量,然后打印出所有的属性,没有发现该环境变量。所以我认为用
System.getProperty()得不到环境变量的值。但可以用java.class.path获得类路径。
public class GetClasspath {
public GetClasspath() {
}
public static void main(String args[]){
Properties p = System.getProperties();
Iterator i = p.entrySet().iterator();
while (i.hasNext()) {
System.out.println(i.next());
}