Reputation: 91
I have around 40 to 50 class files, and none have a main method or a manifest file. Now I have to create a JAR
file from these files. How do I do this?
Upvotes: 9
Views: 15089
Reputation: 272337
$ jar cf myjarfile.jar *.class
will create a jar file with a manifest containing info about the jar file, but without specifying a main class. A main class is not mandatory (e.g. if you're simply creating a library and not an application jar)
Or (perhaps more what you want), the M
flag
$ jar cMf myjarfile.jar *.class
will create the jar file without the manifest.
Upvotes: 15
Reputation: 241
Try this (Linux).
zip -r jar.zip classPathDirHere (just create zip)
mv jar.zip jar.jar (just rename)
Upvotes: -1