0

Please help I want to get the root folder of running jar.

D:\My Folder\My Folder1\ myjarfile

D:\My Folder\My Folder1\My Folder2

I want to save image in MyFolder2 using myjarfile. I have difficulties in coding in getting path of the executable jar:

 String savePath = what goes there?(i want this "D:\My Folder\My Folder1\My Folder2")

 ImageIO.write(image1, "png",new File(savePath));
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user3053928
  • 11
  • 1
  • 4

1 Answers1

3

Do not save settings in the same directory as the Jar!

It is better to save them in a (sub) directory of user.home. That is a path that:

  1. Is easy to reproduce.
  2. The app. should have 'write permission'.

Also consider using Preferences instead.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433