4

I want to create a jar file in Netbeans using the clean and build options. The jar file is created, but the manifest file is not updating; this means the main class is not set in the manifest file, so when I run the jar file, it has the "could not load main class" error.

How do I handle this and how do I add main class in project properties?

JoshDM
  • 4,939
  • 7
  • 43
  • 72
user1952211
  • 86
  • 1
  • 8

3 Answers3

0

Right click on netbeans project and select "Properties" Then select "Run". There is option for selecting main class. Select main class from there.Then click "ok". After doing this try run your project at least once before building your jar file.

Fathah Rehman P
  • 8,401
  • 4
  • 40
  • 42
0

Hope You did not set up main class in project setup.

So do right click on project. then go to properties.

On that screen you can see Run configuration.

There is place to configure main class of you jar file. So configure your main class at there and press ok.

Then clean and rebuild the project.

After that manifest file should update. Look this screen shot.

Chamly Idunil
  • 1,848
  • 1
  • 18
  • 33
0

May be you are running your project using shift+F6 key. You should run your project once by pressing F6 key only then the netbeans gives option to select main class then after that clean and build.