Posted on 2007-05-08 17:23
bluoy 閱讀(191)
評(píng)論(0) 編輯 收藏
JVM‘s current path:
System.getProperty("user.dir");
但是JDK中使用curdir的方法并不一致,比如File.exists() VS File.getAbsolutePath().
user.dir可以通過setProperty()修改,這樣就會(huì)導(dǎo)致上面兩個(gè)函數(shù)結(jié)果相左。
不知道這是否算是JDK的一個(gè)BUG.
IDE Debug mode:
curdir往往由所使用的IDE來決定,比如eclipse,是當(dāng)前打開的project的根。
這與程序?qū)嶋H運(yùn)行時(shí)的curdir是不同的。在debug模式下需要考慮這一點(diǎn)。
Java program runtime:
curdir是classes或bin。
取得方法:DummyClass.class.getResource("/").getPath();