Aditya
Aditya

Reputation: 91

How to create a jar without manifest file and main class?

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

Answers (2)

Brian Agnew
Brian Agnew

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

Les
Les

Reputation: 241

Try this (Linux).

zip -r jar.zip classPathDirHere (just create zip)
mv jar.zip jar.jar (just rename)

Upvotes: -1

Related Questions