System.getProperties() 可以取得各種特性
import java.util.Iterator; import java.util.Properties; import java.util.Set; public class GetExecProperty { static String execSimerPath = ""; public static void showSupplyProperties() { Properties pros = System.getProperties(); Set s = pros.keySet(); Iterator it = s.iterator(); while (it.hasNext()) { String keystr = it.next().toString(); String tempstr2 = System.getProperty(keystr); System.out.println("key: " + keystr + " ,value: " + tempstr2); } } /** * return path of jar */ public static String getExecPath() { String tempstr = ""; String local = System.getProperty("user.dir"); System.out.println("System.getProperty user.dir: " + local); String[] spilttemp = local.split("\\"); for (int i = 0; i < spilttemp.length; i++) { tempstr = tempstr + spilttemp[i] + "\\"; } System.out.println("tempstr: " + tempstr); return tempstr; } }