I'm using Netbeans to build a jar. When I press f6, the project runs fine within Netbeans. However, if I go into my /dist/ folder and try to run the .jar, it just opens it as if it were a .zip. If I try to run the project from command line, I get the 'Could not find main class' error. However if I browse the .jar, and look in the META-INF/manifest.mf file, I can see that it did describe a main class within it.
My packages are named as myname.project, and the main class is named myname.project.Main.
Any ideas what the issue is?
The correct way to run a runnable jar-file is with the -jar
switch.
java -jar path/to/file.jar
An alternative way to run a jar file without the mainclass specified in the manifest (or if there are several main classes for some reason would be the standard
java -cp path/to/file.jar com.foo.Main