“Could not find the main class. Program will exit.”

Ant, eclipse Add comments

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
 

41 Responses to ““Could not find the main class. Program will exit.””

  1. David Tarico Says:

    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.

  2. joc Says:

    I can only aggre with Daid Tarico. Thanks for descriping and reporting

  3. Rahul Says:

    Thanks Christophe,

    It was so simple, but didn’t got noticed

  4. Aigloss Says:

    Just want to say Thanx for such an easy solution!!!! :)

  5. Brian Says:

    I get the same problem, but your solution did not work for me. The ANT HOME is set correctly. Any other ideas???????

    TIA

    Brian

  6. Brian Says:

    I had to get ANT out of my PATH before I ran eclipse to make this work.

  7. De Wet Says:

    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~

  8. swaroop Says:

    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.

  9. Ams Says:

    txxx man
    u rock

  10. systolix Says:

    Push the “Restore Defaults” Button in the Ant/Runtime Settings and then
    “Apply”. And everything will work fine…

    Jesus is Lord!

  11. Bob Says:

    this may sound stupid but.

    can be done through Window->Preferences->Ant->Runtime

    where is windows lol

  12. Bilkis Says:

    I have tried all the solutions above but it did not work
    what to do???????????

  13. Bilkis Says:

    I still get the error what to do?

  14. David Says:

    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.

  15. Afei Says:

    another solution :
    maybe you had added some external jar to your project, remove them and refresh,then try again…

  16. dk Says:

    THANK YOU!!

  17. Emil Stenström Says:

    Thanks alot! Simple solutions like this is exactly what I want :)

  18. Josh Says:

    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

  19. Paul Schmidt Says:

    Thanks Christophe a nice simple quick solution.

  20. José A. Barba Says:

    Thanks a lot, Christophe. I got the same problem.

  21. imparare Says:

    Interesting comments.. :D

  22. Dante Says:

    Thanks for the tip, saved me hours and hours of fiddling. :)

  23. Stephen NG Says:

    Awesome! That worked perfectly!

  24. Matt Says:

    Thanks, this worked for me.

  25. Jerry Says:

    !!! sweet !!! worked for me too just like that !

  26. SneG Says:

    thx man
    rock!!!!!!!

  27. UshaKiron Says:

    Hey very nice, easy & simple solution.

    Thanx Chris :)

  28. flory Says:

    I use Resion in my project.
    The similar problem occured and the solutions above don’t work.
    SOS!!!

  29. guillaume Says:

    Same issue but resolved after changing the ant home, I had to “validate” it by expanding ant home entries…

  30. chirag Says:

    when i double click on myApp.jar
    error display could not find the main class program will exit
    plz give me solution

  31. wow gold Says:

    good!

  32. Rocky Says:

    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!!!

  33. confusion:( Says:

    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..

  34. Agelina Says:

    I’m very new to Eclipse. How can I find the added external jars? And How can I remove and refresh? Please help! Thanks.

  35. Agelina Says:

    I got it works by copy and past the Test.class into the {project-name}/classes directory. What’s wrong with my set up?

  36. Agelina Says:

    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!

  37. Joe Says:

    I had the problem for some time. Now it’s been solved. Thanks a lot!

  38. rooh47 Says:

    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

  39. DarkMan Says:

    Thank you very much! Worked perfectly!

  40. gala Says:

    Thanks, its a great help

  41. Chris Says:

    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.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login