So lets say I have JAR file. User creates some text file and wants to save it. I would like to save it in "resources" folder in my JAR so user can read it later.
But how do I get path to this folder?
So lets say I have JAR file. User creates some text file and wants to save it. I would like to save it in "resources" folder in my JAR so user can read it later.
But how do I get path to this folder?
You usually wouldn't do this. Updating a zip file (which is what a jar file is, basically) is non-trivial. Jar files aren't designed to be updated with user content (e.g. their "documents" directory, or an application-specific directory). You should store your user's files in an appropriate directory. (Heck, in many operating systems the program files are installed read only anyway...)
Paths.get(System.getProperty("user.home"), "Documents").Not sure if it is a good idea but it is possible from command line (jar command help):
jar cf myfile.jar dir1/file1.ext1 ;# create jar file and store file1 jar uf myfile.jar dir2/file2.ext2 ;# update jar file with file2 What is possible from command line should be possible thru the Jar Java API
jar command work if the JAR is opened for reading by the JVM? (Also, instead of a command-line solution, there is the JarFile class in the standard library.)