An ant script in eclipse appears could not find the main class problem and solution

Source: Internet
Author: User

Issue background: The original project wanted to recompile the release run, and the result was that the system reported "Could not find the main class" When initializing the ant script under Eclipse. Program would exit. "

Solution: First search the internet for a solution to the problem,

1) myeclipse "Could not find the main class. Program would exit. " 2007-11-18 04:16 p.m.

Now, this is the wrong thing, windows--preferences--java--installed jres--I chose the JDK, it should be the JRE.

I don't know, I'm just going to choose this one, and I've looked it up on the internet, and I've found the following text, but I used it, and it didn't seem to help.

"Could not find the main class. Program would exit. "

February, 2006 at 1:28 pm Filed under General

I just installed the latest available eclipseversion (3.2 milestone 5) and couldn ' t run my ANT builds anymore. The error I got in the alert box is "Could not find the main class. Program would exit. "

The problem was, the ant_home variable was still pointing to the previous Eclipse folder and the solution were simply T o Change the path. This can is 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 instal Lation. Now hits the OK button and try to run the build file again. Everything should work again.

Oh and by the to, I had a really good laugh with the "Run Garbage Collector" button

Http://www.herrodius.com/blog/?p=42

trackback:http://tb.blog.csdn.net/trackback.aspx?postid=1046337

Results: According to the programme, the Eclipse3.3.2 is now used, and the JREs has been changed to 1.4 of the original development, still unsuccessful.

2) "Implementation of ant in eclipse could not find the main class problem and solution"

=====================================================================

This usually happens after swapping another copy of Eclipse. Previously, it was normal to execute an ant script in Eclipse, remove the original eclipse and replace it with another copy or a new version, and the following error occurred in the pop-up window when the ant script was executed:

---------------------------
Java Virtual Machine Launcher
---------------------------
Could not find the main class. Program would exit.
---------------------------
Are you sure
---------------------------

This error is very clear to those who have used Java, and cannot find the main class of Ant. But to tell the truth also bothered me for some time, and did not go into the deep. The crux of the problem is that the ant_home in Eclipse is pointing wrong.

Workaround: Eclipse into Window->preferences->ant->runtime, on the Classpath tab, see the Ant Home Entries pointing to the wrong directory (it still points to your last directory, And this directory should not exist, all you have to do is change the ant home to point to the correct directory, point the Ant Home button, select the ant home directory, such as my eclipse is 3.3.1, Ant Home is the eclipse's plugin directory of org . apache.ant_1.7.0.v200706080842.

Now it's time to execute your Ant script in Eclipse again, and it will work.

============================================================================

Result: Following the above procedure, it is still unsuccessful. (The solution is correct)

Final Solution: The workaround is no different than the above process, and Eclipse enters Window->preferences->ant->runtime, choosing Ant's jar package for two Ant.jar and ant-in its own project. Launcher.jar, after clicking OK, re-executes the ant XML script successfully. I would like to express my thanks to you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.