Saturday, March 18, 2023
HomeSoftware EngineeringMake a Java Jar File Executable

Make a Java Jar File Executable

Let’s say you have got a Java undertaking as follows:

package deal thing;
public class MyProject {
    public static void most important(String...args) throws Exception {
        System.out.println("Hi there world!");

Now you need to construct this and make it a self contained executable Jar.

In the event you do a mvn clear set up or mvn clear package deal, and attempt to run it as follows:

java -jar goal/my-java-1.0-SNAPSHOT.jar

You’re going to get the next error:

no most important manifest attribute, in goal/my-java-1.0-SNAPSHOT.jar

Remedy no most important manifest attribute error

You’ll be able to resolve this error by including the next in your pom.xml file:

                        <mainClass> thing.MyProject</mainClass>

Now construct your answer like this:

mvn clear set up package deal

Then run your standalone Jar as follows:

java -jar goal/my-java-1.0-SNAPSHOT.jar



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments