比如其中有一个class ToolUtil
String baseHome = ToolUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath();

int pos = -1;
if(baseHome.indexOf("/") != -1){
pos = baseHome.indexOf("/lib/");
}else if(baseHome.indexOf("\\") != -1){
pos = baseHome.indexOf("\\lib\\");
}
if(pos != -1){
baseHome = baseHome.substring(0,pos);
}
String osName = System.getProperty("os.name");
if(osName != null && osName.toLowerCase().startWith("windows")){
baseHome = baseHome.replaceFirst("/","");
}
这个baseHome 就是 想要的,刚开始路径是 lib路径