Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

could not find main class error

Thread view: 
jay - 11 Jan 2006 18:42 GMT
Hello all,
I tried to create a runnable jar file but when I double click on it, it
gives me "Could not find the main class. Program will exit." error. I
am sure I specified a main class and the jar file works on a different
computer. I'm just not sure of why it doesn't find the main class on
different computers. Any ideas? Thanks.
Mark Thomas - 11 Jan 2006 18:51 GMT
> Hello all,
> I tried to create a runnable jar file but when I double click on it, it
> gives me "Could not find the main class. Program will exit." error. I
> am sure I specified a main class and the jar file works on a different
> computer. I'm just not sure of why it doesn't find the main class on
> different computers. Any ideas? Thanks.

You need a manifest file in your Jar that identifies the Main Class,
without that the JVM has no way of knowing which class to load & call
main on.

Mark
jay - 11 Jan 2006 19:34 GMT
How would I create a manifest file and in what directory should I put
it in? Also, I failed to mention it earlier but I am using Eclipse to
export the jar file and the last step of the export wizard asks you to
specify the main class, which I did, but the JVM still fails to find
the main class. Doesn't eclipse automatically generate the manifest
file?
David  Wahler - 11 Jan 2006 21:16 GMT
> Hello all,
> I tried to create a runnable jar file but when I double click on it, it
> gives me "Could not find the main class. Program will exit." error. I
> am sure I specified a main class and the jar file works on a different
> computer. I'm just not sure of why it doesn't find the main class on
> different computers. Any ideas? Thanks.

Try running it from the command line, like this (on Windows):

"%JAVA_HOME%\jre\bin\java" -jar myJarFile.jar

That should give you a more specific error message.

-- David
jay - 12 Jan 2006 20:38 GMT
>Try running it from the command line, like this (on Windows):
>"%JAVA_HOME%\jre\bin\java" -jar myJarFile.jar

The jar runs fine on my Windows machine but it displays the error
message when it is run from another machine which I don't have access
to. I'm just trying to figure out why it works on one but not the
other.
Roedy Green - 11 Jan 2006 21:37 GMT
>I tried to create a runnable jar file but when I double click on it, it
>gives me "Could not find the main class. Program will exit." error. I
>am sure I specified a main class and the jar file works on a different
>computer. I'm just not sure of why it doesn't find the main class on
>different computers. Any ideas? Thanks.

Your manifest is screwed up.  Please display the manifest and the jar
directory which you can get with JarLook. see
http://mindprod.com/jgloss/products1.html#JARLOOK

For notes on doing the manifest see
http://mindprod.com/jgloss/manifest.html and follow the links.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

IchBin - 12 Jan 2006 00:29 GMT
>> I tried to create a runnable jar file but when I double click on it, it
>> gives me "Could not find the main class. Program will exit." error. I
[quoted text clipped - 5 lines]
> directory which you can get with JarLook. see
> http://mindprod.com/jgloss/products1.html#JARLOOK 

 http://mindprod.com/products1.html#JARLOOK

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

jay - 12 Jan 2006 20:36 GMT
>Your manifest is screwed up.  Please display the manifest

My manifest file looks like this:

Manifest-Version: 1.0
Main-Class: source.Main

where source is the package main is on. I'm not sure if I need to add
anything else to this file.
Roedy Green - 12 Jan 2006 21:15 GMT
>Main-Class: source.Main

There must be a CrLf after that.

Lets see the Jarlook proof that there is a member of your jar called
source/Main.class

Test your jar with

java -jar thejar.jar

Now work on the double clickable bit.  See
http://mindprod.com/jgloss/associations.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.