set current dir to project/bin
i made a java application which writes a file to the hard disk. The jar file is placed in /home/myname/workspace.
If i run the jar file(right click open with jre), the file is saved on /home/myname. But if i create a script run.sh (which includes java -jar myfile.jar) and run the project with it, it saves the files on the project dir.
Is there any way to set the current dir to the app's dir?
I dont want to say System.setProperty("user.dir", "/home/myname/workspace"); because the users who'll use the software should be able to run in no matter of the dir it is in.
If there's no way to do it in java, can anybody tell me how to create executable files like my run.sh for windows and mac ? I think windows is called .bat file. I know that would work because current dir is the dir the jar file was opened from.