0

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\\
G Jay
  • 127
  • 2
  • 4
  • 10
  • Possible duplicate: http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file – Balduz Dec 04 '13 at 14:27

1 Answers1

2

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

System.getProperty("user.dir");
Deepak Bhatia
  • 6,230
  • 2
  • 24
  • 58
Sorter
  • 9,704
  • 6
  • 64
  • 74