Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
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
 
Java Cowboy
Sheriff
Posts: 16084
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!