如何获取jar包的在执行机上面的路径
2024-09-20 15:22:39
背景: 最近在项目中遇到一个小问题, 几行代码就能解决了
String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
try {
path = java.net.URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String jarPath = new File(path).getParentFile().getAbsolutePath();
最新文章
- Win10命令提示符(cmd)怎么复制粘贴
- 2.5---链表来进行加法,链式A+B(CC150)
- Codeforces 543D Road Improvement(树形DP + 乘法逆元)
- Codeforces Round #235 (Div. 2)C、Team
- js中window.print()去除页眉页脚
- Linux下Scala(2.12.1)安装
- C语言gcc处理过程
- 借鉴 学习 DELPHI 通用函数 哈哈
- iPhone XS 能否经受的起寒冬的考验
- int &;p
- 【MyBatis】解析MyBatis传入参数的问题
- Debian&;&;ubuntu系安装MegaCli
- Python168的学习笔记4
- 1-16-2 LVM管理和ssm存储管理器使用&;磁盘配额
- CoderForces 687C The Values You Can Make (01背包,DP)
- 使用JavaScript OOP特性搭建Web应用
- 拖拽窗口的实现-JQuery实现;
- 【JeeSite】用户管理
- Hello to the cruel world
- python 局部local和全局global变量