Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Java .jar without MANIFEST.MF?

Tags:

java

manifest

Is it possible to run a Java app which doesn't contain MANIFEST.MF file? Of course, there's static main method,just lacks manifest file. And the app is depending on several external .jar files.

If is this possible, how to do that?

like image 594
eonil Avatar asked Mar 25 '13 22:03

eonil


People also ask

How do I create a JAR file without manifest?

Create a Java JAR File Without Manifest If you do not want to include the manifest file to create a JAR file, you can use the alternative method that specifies the main class name with the command. Yet another method to create a JAR file is to specify the classpath and the package qualified class name.

Does a JAR file need a manifest?

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.

Can we create JAR without main method?

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.


1 Answers

It is possible, you can specify the class to run from the command line:

java -cp yourJar.jar your.main.Class 

Same question here:

How to run a class from Jar which is not the Main-Class in its Manifest file

like image 97
BackSlash Avatar answered Oct 10 '22 00:10

BackSlash