FaqNoMainClass

I get the error "Failed to load Main-Class manifest attribute" when trying to run a JAR file

You may have created the project as a "class library" instead of as an "application".

To convert it, create a file manifest.mf in the project directory (can just contain Manifest-Version: 1.0 and nothing else), and make sure project.properties contains:

manifest.file=manifest.mf

Then make sure you set a main class for the project in the properties dialog and select Build->Clean and Build Project. The Main-Class attribute, and any required Class-Path, will be inserted into the JAR's manifest by the build process.

I get the error "Could not find or load main class" when trying to run a JAR file

A Failed to load Main-Class error also may be an execution error. From the command line, executing a jar requires the java -jar option. Otherwise, the count not find or load main class error is returned as Java assume the file is a .class binary.


Applies to: NetBeans 6.x, 7.x

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo