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?
$ 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 (eg 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.
Try this (Linux).
zip -r jar.zip classPathDirHere (just create zip)
mv jar.zip jar.jar (just rename)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.