I have file structure like this. I would like to print the path of jar when i execute from soft link. But i am always getting actual location instead soft link location.
c:\MyDir\MySubDir
MyJar.jar
c:\SoftLink1 --> c:\MyDir\MySubDir
c:\SoftLink2 --> c:\MyDir\MySubDir
When i print current jar file while executing MyJar.jar from SoftLink1 or SoftLink2 using below code, i am getting actual directory instead softlink location.
String path = MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
What is the right way to print current jar file location (Soft link location) when i execute it from different soft links.
对于相对路径:
System.getProperty("sun.java.command")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.