This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes getting error that main class cannot be found??! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting error that main class cannot be found??!" Watch "getting error that main class cannot be found??!" New topic
Author

getting error that main class cannot be found??!

Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
Ok, I am looking for some help again. I am trying to work on this heap program and I am learning java while I do it.

I am getting this error on compile:
Could not find the main class. Program will exit.

I am using Eclipse 3.1.0

I know it's a lot of code, but I am not sure what to leave out.

Any help is really, really appreciated.


[ September 29, 2004: Message edited by: Rick Harding ]
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Rick,

I ran your program without any problem, so there is nothing wrong with the code.
I do not the exact cause of the problem, but it could be a classloader issue.

Try to compile and run your code from the command line, if you were doing it through Eclipse earlier.

This is just a wild guess, but do you have multiple JRE's on your system? If you do check that only one is on the path and classpath.

cheers,
Sonny


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
What your OS to run this file ?

p.s.

This could also mean that the directory path has filenames longer that eight (8) characters


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
It's on Windows XP. I am honestly not sure what I hit, but I hit something that ran it differently from eclipse.

I tinkered with the drop down and it seems to be working again.

Guess that is just some fun of learning a new language.
Rainman
Greenhorn

Joined: Sep 30, 2004
Posts: 2
Rick,

Sounds like you tried to run the class instead of compile. Without a Main the class will compile but not run. Try to run the class and see if this is the error you received.
Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
I figured out what I did because I did it again

In eclipse I changed the name of the class and had it change the name of the compilation for me.

Once I did that I can't run with the run icon. I have to first go and tell it to run as a java application again. If I don't tell it to run as java application it seems to want to run as the old name and can't find that class any longer because it has been renamed.

Thanks for the help all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting error that main class cannot be found??!