Hello friends,
You have been of great help to me till now. I got a new problem , I am unable to run the JAR file.

When i click on the Jar file, I got the following error :

"Could not find the main class: socketprog.Main. Program will exit."

Thanks in advance for your answers.

Recommended Answers

you are trying to run the jar file

do you have this in there?

public static void main(String [] args)

i'm assuming you don't, but for a jar file to be run, just like any other code, it needs to start with a main method

Jump to Post

Executable jar files need a Main-Class: entry in the manifest file.
More info here: http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

Jump to Post

You should be able to set the main class in the project properties in the "Run" section.

Jump to Post

All 10 Replies

you are trying to run the jar file

do you have this in there?

public static void main(String [] args)

i'm assuming you don't, but for a jar file to be run, just like any other code, it needs to start with a main method

Thanks for the answer, yeah of course I have the main method. The program run normally when I compiled it with the compiler. But I just want it to run like an exe file, without the need to compile it again and again.

Thanks.

Thanks ezzaral, but I know it has something to do with manifest file. Can you help me to do it with Netbeans please. I got some tutorial but its not working.
Thanks again.

You should be able to set the main class in the project properties in the "Run" section.

Hello Ezzaral,
Wow ... its working now. Yuppie .. you are too good. Its have nothing to do with "manifest" file then.

Can you please explain to me, what does the manifest file do ?? I am just curious.

Thanks guys, thanks a lot.

The manifest file specifies where the main class is, that way the program can run as you want it to. And netbeans generates the manifest file for you, so you don't see the details of it, but I'm sure that it happens. The manifest file can also do other things, I think, but I'm not sure what they are. See here for more info:

http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

Thanks for the answer BJSJC. ;)

Hello Ezzaral,
i m doing the same thing... i have Table.jar which contain manifest file...

Manifest-Version: 1.0
Main-Class: org.lan.Table

Can you please explain me what i am doing wrong....

Thank you so much Ezzaral :)))
I did what you said about the properties under the project and everything seems fine now:)
The only problem I have is that the icons of the buttons I have in the interface are not shown or recognized:( What can I do? Please answer me;)

Be a part of the DaniWeb community

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