Re: Beginner Problem - Manifest file
On 30/05/11 21:53, William Colls wrote:
Ubuntu 10.04.2 64 bit
I have built a small application containing two classes. When I build
the application in the IDE, it builds without error, and creates a .jar
When I try to run the .jar using the command
java -jar myapp.jar
I get the error
Failed to load Main-Class manifest attribute from myapp.jar
One of the class files does contain the main declaration
public static void main(String args)
From my reading, I understand that there should be a file with the name
manifest.txt in the build directory that gets incorporated into the .jar
file, but I don't know what the contents of the file should be. My
original understanding of how the IDE worked led me to believe that it
would create the manifest file automatically, but this doesn't seem to
Any guidance would be greatly appreciated.
Thanks for your time.
You shouldn't need to worry about manifest files in NetBeans - provided
you create the correct type of project. If you create a project of type
"Java Application", and in the next dialog box check "Create Main
class", NetBeans will do everything for you. It will create the main
class and the manifest, and since it knows which is the main class it
will add that information to the manifest.
What type of project did you create? It's not always possible to modify
the project type after the fact, the attributes of some project types
are not suitable. You may be able to do it by creating your main class
(a class with a main method), then editing the project properties. In
the Run category set the Main Class attribute to your main class. If
that doesn't work, and you want NetBeans to manage the project for you
by creating properly runnable jar files, the simplest way may well be to
create a new project of the correct type. Then move your existing Java
files into that project, using NetBeans to move/refactor the classes.