📜  java 获取 jar 文件的位置 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:10.164000             🧑  作者: Mango

代码示例1
//this worked for me
File jarDir = new File(ClassLoader.getSystemClassLoader().getResource(".").toURI());

//this didn't work for me but it is often suggested
File jar = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI());