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

When i try to compile a jar file using the below command in command prompt,

java -jar HelloWorld.jar
i got an error like

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

This is due to the missing launch configuration. 

The Main-Class header needs to be in the manifest for the JAR file - this is metadata about things like other required libraries. See the Sun documentation for how to create an appropriate manifest.

Simply, i followed the eclipse for exporting the jar file instead of remembering all the commands.
















and choose as specified below.























and choose the following options below.

1. Choose your class that contains MAIN method.
2. Choose the destination of Jar file
3. Once, one and two steps are done, Click Finish.
























Now run the same command via command prompt, 

java -jar HelloWorld.jar
This will not throw any Main-Class error.


Enjoy Learning!

Comments

Popular posts from this blog

[SOLVED] - RSYNC not executing via CRON

RSYNC command without authentication - 8 simple steps

Install JDK on Ubuntu