I know this is a very common question, but I tried googling and got no helpful result.
I’m trying to make a jar out of my “Main.class” file (made in NetBeans, but I’m not trying to make the jar with it)
I ran this command:
D:\NetBeans\trovanum3\build\classes\trovanum3>jar cf trovanum.jar *.class
And a .jar file spawned in that folder. I thought that would’ve worked, but it won’t run.
I tried opening the jar file with an archive opener and inside it are the “Main.class” file and a “META-INF” folder containing a file named “MANIFEST.MF”
The file contains this:
Manifest-Version: 1.0
Created-By: 1.6.0_22 (Sun Microsystems Inc.)
What could be the problem?
You can use the
-eoption of jar to specify the entry point, i.e. the main class. For example:Saves fiddling with the manifest if that’s all you need in there. Note the working directory is one up from that quoted in your question. Otherwise the Main class is created at the top-level in the jar, rather than in a directory that reflects the package in which it should reside.
jar -tvfshould then show something like this: