简体   繁体   中英

find the executable jar file location in java

Is is possible to find my executable jar file running location, from that jar file jave code,

For example I may run one particular jar file from d:\\test\\finloc.jar, It should print the path as

  d:\\test

I may run from C:\\users\\GJ\\Documents\\findloc.jar, then its output should be like

  C:\\users\GJ\\Documents\\

Following code outputs the path from where the application starts.
In your case, the jar file.

System.getProperty("user.dir");

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM