• Post Reply Bookmark Topic Watch Topic
  • New Topic

Failed to load Main-Class manifest attribute from HelloWorld.jar  RSS feed

 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am trying to create a simple jar file "HelloWorld.jar"

In command prompt,went to location

"D:\test-workspace\JavaJar\bin" where "HelloWorld.class" is present.

Created "manifest.txt" and put "Main-Class: HelloWorld"

D:\test-workspace\JavaJar\bin>jar cfm HelloWorld.jar Manifest.txt HelloWorld.class

jar file is created "HelloWorld.jar"

I try to run the jar file

D:\test-workspace\JavaJar\bin>java -jar HelloWorld.jar

But error is thrown as

Failed to load Main-Class manifest attribute from HelloWorld.jar

I have extracted the jar file and look into it

I can see HelloWorld.class and MANIFEST.MF

But MANIFEST.MF is blank

I have already mentioned in "manifest.txt" as "Main-Class: HelloWorld"

How can i run the execute the jar file?

Regards,
Anand
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16044
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try this command to create the JAR file:

jar cfe HelloWorld.jar HelloWorld HelloWorld.class

The "e" option is to set the entry point, this would create the manifest automatically with the correct entry point. See this tutorial.
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:You can try this command to create the JAR file:

jar cfe HelloWorld.jar HelloWorld HelloWorld.class

The "e" option is to set the entry point, this would create the manifest automatically with the correct entry point. See this tutorial.


Thanks Jesper de Jong!!!

its working fine
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!