when I am trying to run the jar file is give me the message fail to load Main-Class manifest attribute from..... I am programming using netbeans IDE 5.5 any help

Dani AI

Generated

Short, practical explanation and checklist.

The "fail to load Main-Class manifest attribute" message means the JVM could not find a valid Main-Class entry the runtime can read. That usually comes from either a missing or malformed MANIFEST.MF, a wrong fully-qualified class name, or the main class not being present in the JAR. As discovered, letting the IDE write the manifest (set the project's main class and rebuild) is the simplest fix; below are safe troubleshooting steps and common pitfalls.

Quick diagnostic steps

  • Run the JAR from a terminal to get the real error: java -jar myapp.jar.
  • Inspect the JAR and extract the manifest (use the jar tool or a zip viewer) to confirm META-INF/MANIFEST.MF is present and readable.
  • A minimal, correct manifest looks like:
Manifest-Version: 1.0
Main-Class: com.example.Main

(Important: Main-Class must be the fully qualified class name and the file ends with a blank line. The class must implement public static void main(String[] args).)

Common causes and fixes

  • Editing the manifest inside a built JAR with a GUI zipper or an editor that adds a BOM/extra bytes can corrupt the archive or render the manifest unreadable. Rebuild from the project (Project Properties -> Run, set main class, then Clean and Build) or update the manifest safely with the jar tool rather than hand-editing the ZIP.
  • To inspect contents: jar tf myapp.jar and to extract the manifest: jar xf myapp.jar META-INF/MANIFEST.MF.
  • To update a manifest without recreating the whole archive: use the jar update option, e.g. jar ufm myapp.jar manifest.mf.

Quick checklist

  • MANIFEST.MF exists and contains Main-Class: with the correct fully-qualified name.
  • The main class is included in the JAR and has the correct signature.
  • Manifest file ends with a blank line; avoid editors that add BOM.
  • If double-clicking reports "corrupted file", run from a terminal to rule out file association issues.

Credit: and pointed to creating and managing the manifest and learning the command line; ’s NetBeans solution is the simplest practical route.

Recommended Answers

All 9 Replies

Did you create the jar file using a manifest file?

e.g. >jar cvfm myjar.jar *.class

Did you specify the main class?

just check out the manifest file

In that manifest file specify your main class correctly. then it will work fine

as I describe I am using netbeans and when I try to modify the netbeans created and compile it . and then try to compile it complaines "corrupted file" when trying to run double clicking the jar file .

Then do it with command propmpt here is some explanation

commented: good +12

guys thanks very much I got the solution . in netbeans5.5 simply in the project properties select the run panel and enter the main class name then build the project that is all .

That is fine but you should also learn how to do it from command line as you may not always have NetBeans

ok thanks I will.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.