943,713 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 33146
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Apr 8th, 2009
0

Jar File Problem, Could not find the main class....

Expand Post »
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.
Similar Threads
Reputation Points: 6
Solved Threads: 0
Junior Poster
neutralfox is offline Offline
124 posts
since Mar 2009
Apr 8th, 2009
0

Re: Jar File Problem, Could not find the main class....

you are trying to run the jar file

do you have this in there?

Java Syntax (Toggle Plain Text)
  1. 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
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Apr 8th, 2009
0

Re: Jar File Problem, Could not find the main class....

Executable jar files need a Main-Class: entry in the manifest file.
More info here: http://java.sun.com/docs/books/tutor...ar/appman.html
Last edited by Ezzaral; Apr 8th, 2009 at 2:00 pm.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,759 posts
since May 2007
Apr 8th, 2009
0

Re: Jar File Problem, Could not find the main class....

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.
Reputation Points: 6
Solved Threads: 0
Junior Poster
neutralfox is offline Offline
124 posts
since Mar 2009
Apr 8th, 2009
0

Re: Jar File Problem, Could not find the main class....

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.
Reputation Points: 6
Solved Threads: 0
Junior Poster
neutralfox is offline Offline
124 posts
since Mar 2009
Apr 8th, 2009
0

Re: Jar File Problem, Could not find the main class....

You should be able to set the main class in the project properties in the "Run" section.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,759 posts
since May 2007
Apr 12th, 2009
0

Re: Jar File Problem, Could not find the main class....

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.
Reputation Points: 6
Solved Threads: 0
Junior Poster
neutralfox is offline Offline
124 posts
since Mar 2009
Apr 12th, 2009
0

Re: Jar File Problem, Could not find the main class....

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/tutor...ar/appman.html
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
Apr 12th, 2009
0

Re: Jar File Problem, Could not find the main class....

Thanks for the answer BJSJC.
Reputation Points: 6
Solved Threads: 0
Junior Poster
neutralfox is offline Offline
124 posts
since Mar 2009
Nov 8th, 2010
0
Re: Jar File Problem, Could not find the main class....
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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sa86 is offline Offline
1 posts
since Nov 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Need help getting started thanks
Next Thread in Java Forum Timeline: Low image quality after zooming in/out





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC