How to Make a Java Jar File Executable
Let’s say you have a Java project as follows:
Now you want to build this and make it a self contained executable Jar.
If you do a mvn clean install
or mvn clean package
, and try and run it as follows:
|
|
You will get the following error:
no main manifest attribute, in target/my-java-1.0-SNAPSHOT.jar
How to Solve no main manifest attribute
error
You can solve this error by adding the following in your pom.xml
file:
|
|
Now build your solution like this:
|
|
Then run your standalone Jar as follows:
|
|