This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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

getting error that main class cannot be found??!

Rick Harding

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


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.


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 ?


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

Java Developer, Thailand
Rick Harding

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.

Joined: Sep 30, 2004
Posts: 2

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

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:
subject: getting error that main class cannot be found??!
Similar Threads
Help with adding elements to vector
what do this do?
help reading in file of integers
Unable to add object to array.
Questions in relation to a queue.