Answer the question
In order to leave comments, you need to log in
How to fix "no main manifest attribute" error?
For some reason I am unable to create an executable jar archive. All the time I run it it comes out "no main manifest attribute".
Here is the source code:
package package1;
public class Dime2{
public static void main(String [] args){
try{
System.out.println("Hello world");
Thread.sleep(10000);
} catch(Exception exc){}
}
}
javac package1/Dime2.java
jar cfm dime.jar manifest.txt package1/Dime2.class
Answer the question
In order to leave comments, you need to log in
Good afternoon!
I can assume problems in the manifest file itself:
There is no line break in the MANIFEST.mf or Manifest.txt file. Because of what it ignores your file. You can verify this if you open the jar with some archiver and look into the directory MANIFEST/MANIFEST.mf
Here, a simple working example:
The structure of directories and files:
folder/package1/Dime2.java
folder/package1/Dime2.class
folder/MANIFEST.mf
javac Dime2.java
jar cfm dime.jar MANIFEST.mf package1/*.class
Main-Class: package1.Dime2
package package1;
public class Dime2{
public static void main(String [] args){
try{
System.out.println("Hello world");
Thread.sleep(10000);
} catch(Exception exc){}
}
}
chmod a+x dime.jar
java -jar dime.jar
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question