Unable to execute jar- file no main manifest attribute

973    Asked by BenjaminMoore in Python , Asked on Jul 19, 2021

 I have installed an application, when I try to run it (it's an executable jar) nothing happens. When I run it from the commandline with:

java -jar "app.jar"

I get the following message:

no main manifest attribute, in "app.jar"

Normally, if I had created the program myself, I would have added a main class attribute to the manifest file. But in this case, since the file is from an application, i cannot do that. I also tried extracting the jar to see if I could find the main class, but there are to many classes and none of them has the word "main" in it's name. There must be a way to fix this because the program runs fine on other systems.

Answered by Behailu
  That should have been java -jar app.jar instead of java -jar "app".

The -jar option only works if the JAR file is an executable JAR file, which means it must have a manifest file with a Main-Class attribute in it. See Packaging Programs in JAR Files to learn how to create an executable JAR. If it's not an executable JAR, then you'll need to run the program with something like: java -cp app.jar com.somepackage.SomeClass where com.somepackage.SomeClass is the class that contains the main method to run the program. (What that class is depends on the program, it's impossible to tell from the information you've supplied). This may help you solve java no main manifest attribute error.



Your Answer

Interviews

Parent Categories