0

I am writing a program which is dependent on saving to a resource folder that is exported with the jar. I have a source folder titled "resources/inputs" and it exports correctly. I can load from it which is great, but the problem is, when I use:

getClass().getResource(path);

I cannot save to the path returned. I need to be able to save to it and I was wondering, is there any way I can save to this resource folder (or to some other folder existent in the same directory as the jar) no matter where the user has saved the jar file?

The error I get is a FileNotFoundException and the background I've read on it is that since jar triggers java "read-lock" you can only ever read from a jar and can never write to it? Not sure if that is accurate or not, but if it is, how can I work around this using an external folder?

Jason McKindly
  • 463
  • 1
  • 8
  • 15

1 Answers1

0

I've never tried this, but its probably having a hard time because the you need to use specialized classes to access files within a jar file (which is a zip file with a different extension). Google "JarEntry" and see if that points you in the right direction.

Does this answer your question

Community
  • 1
  • 1
sevensevens
  • 1,703
  • 16
  • 27
  • I am going to try writing to the user's Temp Directory first, if I can't get that to work, I'll give JarEntry a shot. Thanks for the help – Jason McKindly Jul 03 '13 at 17:14