获取当前jar包的绝对路径

来源:互联网 发布:彩蝶排课软件 编辑:程序博客网 时间:2024/06/16 03:39
String jarWholePath = MyClass.class.getProtectionDomain().getCodeSource().getLocation().getFile();  
try {  
    jarWholePath = java.net.URLDecoder.decode(jarWholePath, "UTF-8");  
} catch (UnsupportedEncodingException e) { System.out.println(e.toString()); }  

String jarPath = new File(jarWholePath).getParentFile().getAbsolutePath();  

阅读全文
0 0
原创粉丝点击