I just installed the latest available Eclipse version (3.2 milestone 5) and couldn’t run my ANT builds anymore. The error I got in the alert box was “Could not find the main class. Program will exit”.
The problem was that the ANT_HOME variable was still pointing to the previous Eclipse folder and the solution was simply to change the path. This can be done through Window->Preferences->Ant->Runtime. Once there, click the “Ant home…” button in the “Classpath” tab and browse to the ANT plugin folder in your Eclipse installation. Now hit the OK button and try to run the build file again. Everything should work again.
Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
Christophe Herreman is a software developer living in Belgium. He's working on Flex based e-learning solutions at
February 24th, 2006 at 2:31 am
Thanks tons! I was having the same problem and even though it was trivial to fix, the hard part was figuring out what the problem was and where to go to fix it. I’m always thankful when altruistic people such as yourself post solutions to their problems.
March 24th, 2006 at 3:49 pm
I can only aggre with Daid Tarico. Thanks for descriping and reporting
April 10th, 2006 at 8:19 am
Thanks Christophe,
It was so simple, but didn’t got noticed
May 12th, 2006 at 3:49 pm
Just want to say Thanx for such an easy solution!!!!
May 25th, 2006 at 1:42 am
I get the same problem, but your solution did not work for me. The ANT HOME is set correctly. Any other ideas???????
TIA
Brian
May 25th, 2006 at 2:06 am
I had to get ANT out of my PATH before I ran eclipse to make this work.
June 6th, 2006 at 12:15 pm
i had the same problem but it was just that one second it worked and the next it didnt. Well not exactly, I added the sun fscontext.jar and providerutil.jar files to my project and then eclipse wouldnt run apps any more
At least the info here seems to help a bit
ty
D~
July 11th, 2006 at 12:06 am
The reson for that error was check for the vm args I the link of javadoc in place of vm args then I got such an error check for that and see.
August 11th, 2006 at 2:54 pm
txxx man
u rock
September 6th, 2006 at 7:51 am
Push the “Restore Defaults” Button in the Ant/Runtime Settings and then
“Apply”. And everything will work fine…
Jesus is Lord!
October 18th, 2006 at 7:53 pm
this may sound stupid but.
can be done through Window->Preferences->Ant->Runtime
where is windows lol
January 3rd, 2007 at 12:26 pm
I have tried all the solutions above but it did not work
what to do???????????
January 3rd, 2007 at 2:08 pm
I still get the error what to do?
January 10th, 2007 at 12:11 am
I have a similar problem. When running a simple java class just containing a main method that does System.out.println(”Test”) from inside eclipse I get the message “Could not find the main class. Program will exit”. On the other hand, when I execute the generated class file from cmd shell with “java ” command the operation is successful and the program is launched successfully.
January 16th, 2007 at 11:31 am
another solution :
maybe you had added some external jar to your project, remove them and refresh,then try again…
February 1st, 2007 at 1:08 am
THANK YOU!!
February 15th, 2007 at 12:34 pm
Thanks alot! Simple solutions like this is exactly what I want
February 16th, 2007 at 12:51 am
I have the same problen but when i’m installing macromedia coldfusion and i don’t know what else to do… maybe you can help me with this…
thanx
March 13th, 2007 at 10:20 am
Thanks Christophe a nice simple quick solution.
March 21st, 2007 at 10:39 am
Thanks a lot, Christophe. I got the same problem.
April 15th, 2007 at 7:11 am
Interesting comments..
June 19th, 2007 at 3:55 pm
Thanks for the tip, saved me hours and hours of fiddling.
August 24th, 2007 at 7:29 pm
Awesome! That worked perfectly!
August 30th, 2007 at 11:48 pm
Thanks, this worked for me.
September 10th, 2007 at 2:44 am
!!! sweet !!! worked for me too just like that !
September 12th, 2007 at 6:41 pm
thx man
rock!!!!!!!
September 26th, 2007 at 11:35 am
Hey very nice, easy & simple solution.
Thanx Chris
October 3rd, 2007 at 3:24 pm
I use Resion in my project.
The similar problem occured and the solutions above don’t work.
SOS!!!
October 15th, 2007 at 12:01 pm
Same issue but resolved after changing the ant home, I had to “validate” it by expanding ant home entries…
November 30th, 2007 at 8:15 am
when i double click on myApp.jar
error display could not find the main class program will exit
plz give me solution
December 17th, 2007 at 8:08 am
good!
December 21st, 2007 at 1:31 pm
Christophe, Thanks a ton for this nice simple and quick solution. I was able to resolve my which I was not able to figure out.
You rock buddy!!!
January 2nd, 2008 at 9:58 am
This may be very silly but still, here i am running my project from the shell when i run the ant command target folder is created with .jar files in it. Now when i try to run the .jar file with javaw it gives the above error that “could not find…”. can anyone solve this problem in the meta-inf folder created there is not .mf (manifest file) created wen the project is built. please reply..
January 7th, 2008 at 9:50 pm
I’m very new to Eclipse. How can I find the added external jars? And How can I remove and refresh? Please help! Thanks.
January 7th, 2008 at 10:20 pm
I got it works by copy and past the Test.class into the {project-name}/classes directory. What’s wrong with my set up?
January 7th, 2008 at 11:35 pm
I resolved the problem now. Thanks!
The problem is that my simple Java class did not compiled inside Eclipse (when I hit Build Project) due to another classes in the same package got errors and I didn’t see the error message until now. After fix the error messages and build again and make sure that the HelloWorld.call is there in my {project-name}/classes directory, it works!
January 15th, 2008 at 1:10 pm
I had the problem for some time. Now it’s been solved. Thanks a lot!
February 11th, 2008 at 4:18 pm
Dear All,
i am just posting this may it can help someone,i had same probem when i run project on elipse,actually on elipse we had to manage lot of configurations, some time when you people are adding some lib to project then you have to check its setting if you got error.
Solution to Error in my Case,
Default Setting for Compiliance level is 6.0 in elipse and if you have any lower version of jdk then 6.0 then you have to change that according to your Compiler version,then you will not see that error again,
you can change level from:::Windows->Preferences->Compiler->Compler Compiliance level
thanks to all
February 15th, 2008 at 4:55 pm
Thank you very much! Worked perfectly!
April 10th, 2008 at 1:04 am
Thanks, its a great help
May 12th, 2008 at 1:55 pm
Hi,
Thanks for this fix. As a side note, you will also get this error if you make a mistake when inputting VM arguments. For instance, I forgot the ‘-’ in front of one of my VM args and got the same error, so if the above fix doesn’t work then check your VM args.