I am trying to run a jar file from the console:
java -jar ScrumTimeCaptureMaintenence.jar
And am getting the error:
Can't execute jar- file: “no main manifest attribute”
As you can see I do in fact have a main file and it runs fine from eclipse:
What do I need to do to successfully run this file from the command line?
Try to run
java -cp ScrumTimeCaptureMaintenence.jar Main
In Eclipse: right-click
on your project -> Export
-> JAR file
At last page with options (when there will be no Next
button active) you will see settings for Main class:
. You need to set here class with main
method which should be executed by default (like when JAR file will be double-clicked).
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.
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.
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