Wednesday, May 17, 2023
HomeSoftware EngineeringMethods to Make a Java Jar File Executable

Methods to Make a Java Jar File Executable

Let’s say you will have a Java challenge as follows:

bundle thing;
public class MyProject {
    public static void predominant(String...args) throws Exception {
        System.out.println("Good day world!");

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

If you happen to do a mvn clear set up or mvn clear bundle, and attempt to run it as follows:

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

You’ll get the next error:

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

Methods to Clear up no predominant manifest attribute error

You may clear up this error by including the next in your pom.xml file:

                        <mainClass> thing.MyProject</mainClass>

Now construct your resolution like this:

mvn clear set up bundle

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