获取类根路径及jar包路径

public File  getClassRootDir(Class classz){
   String filePath = classz.getProtectionDomain().getCodeSource().getLocation().getFile();
   return  new File(filePath);
}
public File getJarFile(Class classz){
    String filePath = classz.getProtectionDomain().getCodeSource().getLocation().getFile();
    return  new File(filePath);
}

猜你喜欢

转载自java12345678.iteye.com/blog/2301361