Is there a way to change working dir for JVM when running Java Webstart? When i use system.setProperties("user.dir", newDir) it sets it(system.getProperties() shows it does) but ignores it.
Is this a limitation in Java Webstart to always use the working dir where i started the jnlp file? I am using all permissions in the jnlp file.
Please help!
EDIT: Whatever i do now, my webstart always uses user.dir to save files. Frustrating!
I've had this question in the past myself, but I've always found that, in the end, I didn't need it. Why do I say this?
Because your java web start app is not like an executable run from Program Files
. It doesn't even exist on your computer like most programs (it is broken up into a bunch of different files and reassembled by the JVM). Therefore, you cannot say that the program has its own directory to do what it needs.
But it doesn't need to. Here's why:
Preferences
API to help when you need to store data. The under-workings of the Preferences
API is as mysterious as JWS, thus they are really a perfect fit. Either way, if you need to write things to a file, you should check this API to see if it can meet your needs.user.home
resource as @AndrewThompson suggested. This will be "your" directory and is as good (in fact, better) than a directory in Program Files
(if you're running on Windows, as an example).In conclusion, in all cases (that I've come across), there's no need to change your current working directory. If you need your own folder, create one in user.home
(because you won't run into file permissions issues there).