First: I realize that this issue should be quite simple and lots of people seem to have experienced it. However, it appears my issue may be slightly different from existing posts.
I'm using NetBeans to compile a Java application. When it's done building, the output goes into the dist\ folder correctly. The jar file is present there. If I go to the command line, navigate to that folder, and call the following:
java -jar Prosperity.jar
everything works fine. Obviously the name of the application is Prosperity. The following command also works fine:
javaw -jar Prosperity.jar
However, double-clicking the .jar file gives the message: "Could not find the main class:", and then gives the path to the .jar file. I've checked a hundred times that the META-INF folder exists inside the .jar file, and that within it there exists a MANIFEST.MF with the correct main class name. I have also checked that the main class (App.class) .class file exists inside the .jar file.
So the question is: what's the difference between double-clicking a file and running javaw on it? It's getting really frustrating that it won't just run!
Thanks for any direction you can give me, I'm tearin' my hair out here!
Perhaps your file associations got messed up. At the command prompt, try running
ftype | find "jarfile"
On my 64-bit Windows 7 computer, that shows
jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*
You can also change it with ftype
:
ftype jarfile="C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -jar "%1" %*