Search code examples
javajarjavac

Jar File: no main manifest attribute, in file.jar


I was building a jar file featuring one class, Main. It was based off Main.java:

public class Main {
  

  public static void main(String[] args) {
   System.out.println("hello jar file:-/");
  }

  
}

I compiled with this command: javac Main.java

Made this manifest.txt:

Main-Class: Main

And finished with: jar cfm myfirstjarfile.jar manifest.txt Main.class

When I run java -jar myfirstjarfile.jar I get this error: no main manifest attribute, in myfirstjarfile.jar

I was then told to put manifest in META-INF and call it MANIFEST.MF but I can't compile it, so what command do I use to turn this into a jar?

Anyone know why? Thank you!


Solution

  • I figured it out.

    jar cvfe main.jar Main Main.class