0

As the title says, is there a way to get the current location of the .jar that is begun open, for example i have a file Test.jar and when i run it on desktop it works but when i run it from my documents it just will don't open.

An example of how can it be structured:

if(location == Desktop){
   //Do stuff here
} else {
System.exit(0);
}

Thx for the help! and sorry for my bad English

peti446
  • 330
  • 1
  • 4
  • 12
  • Are you sure you want the location of the jar file? Maybe you want the current working directory instead? – Thilo Mar 04 '15 at 12:44
  • Check out http://stackoverflow.com/a/7603444/1980909 – Adrian Leonhard Mar 04 '15 at 12:44
  • I see from the other post that @AdrianLeonhard put that ` System.getProperty("user.dir"))` will print out the complete path where the jar file is initiate is that correct ? – peti446 Mar 04 '15 at 12:47

0 Answers0