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

Thread Solved

Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

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

 
0
  #1
Apr 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

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

 
0
  #2
Apr 8th, 2009
you are trying to run the jar file

do you have this in there?

  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
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 509
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

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

 
0
  #3
Apr 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

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

 
0
  #4
Apr 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

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

 
0
  #5
Apr 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 509
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

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

 
0
  #6
Apr 8th, 2009
You should be able to set the main class in the project properties in the "Run" section.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

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

 
0
  #7
Apr 12th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,563
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 196
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso

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

 
0
  #8
Apr 12th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 123
Reputation: neutralfox is an unknown quantity at this point 
Solved Threads: 0
neutralfox neutralfox is offline Offline
Junior Poster

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

 
0
  #9
Apr 12th, 2009
Thanks for the answer BJSJC.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC