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?
Yes, but since it is a library this class will be available in it too. It just seems weird to add a class in that has no function whatsoever. just delete the Main class. You didn't need to create it in the first place.
The answer is the JAR file's manifest. The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.
It is easy to resolve this error in the Spring Boot project. To fix this error in the SB project, put the maven-plugin dependency under the <plugins> tag in the pom. xml file.
$ 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With