JAR executable doesn't start if it's in Programs directory
I'm into a very strange issue that's making me crazy .-. I'm working on a relatively big Java project on Windows, using NetBeans and IzPack to prepare the graphical installation package. Everything is ok, the compiled installer seems to work and my program is copied in 'C:\Programs\MyProject' folder.
But... when I double click on the myproject.jar in that folder it doesn't start at all. I obviously tried to open a prompt and type 'java -jar myproject.jar' but nothing, not even a line of error code. The curious facts are two:
- if I open it using the prompt with administration rights it works
- in the same folder there is another jar, 'uninstaller.jar' created by izpack, and it works with double click.
I double checked m开发者_StackOverflow社区y JVM installation, the PATH/JAVA_HOME/... values, and Properties->Security tab of my JAR but the permissions to execute/read/write for every kind of user are ok, and also are equal to the uninstaller.
So what's the problem? Thanks
This is almost certainly caused by Windows UAC on Vista and Windows 7.
Your program is probably trying to write to data files in the same directory as it is installed.
On Windows, well behaved programs write to the users or all users app data directory.
The location of that directory varies depending on the version of Windows.
You can use the system property "user.home" to find a safe place to store data.
You can also get a list of environment variables for shared and per user program data folders from here.
精彩评论