Sunday, May 6, 2012

JAR and File Associations

I have finished my program and I wanted to create a Jar file using netbeans. Everything seems to be working fine when I run the jar file from the command prompt. However, when I decide to double click the jar file in the hopes of having the program run properly, an error came up saying that java was unable to find the specified main class. After googling around I found that the solution to this problem is because the file type associations is not set properly. As I am using windows 64 bit, I would have to use the proper file type associations.


I needed to go to
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command

and changed the value from the original to

"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*

Originally it was something along the likes of

"C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*

Not only was it using the previous version of jre, jre 6, but it was also using the 32 bit version. I suppose this is what caused the error as now it works completely fine

No comments:

Post a Comment