码迷,mamicode.com
首页 > 编程语言 > 详细

如何获取jar包的在执行机上面的路径

时间:2018-07-01 14:55:00      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:cti   support   prot   rac   trace   ted   url   代码   decode   

背景: 最近在项目中遇到一个小问题, 几行代码就能解决了

1 String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
2         try {
3             path = java.net.URLDecoder.decode(path, "UTF-8");
4         } catch (UnsupportedEncodingException e) {
5             e.printStackTrace();
6         }
7         String jarPath = new File(path).getParentFile().getAbsolutePath();

 

如何获取jar包的在执行机上面的路径

标签:cti   support   prot   rac   trace   ted   url   代码   decode   

原文地址:https://www.cnblogs.com/andrew209/p/9249946.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!