Eclipse中執行Ant指令碼出現Could not find the main class的問題及解

來源:互聯網
上載者:User

問題背景:原來做的項目想重新編譯發布運行,結果在Eclipse下執行初始化Ant指令碼時系統報"Could not find the main class. Program will exit."

解決方式:首先在網上搜尋了一下問題解決方案,

1)myeclipse中出現"Could not find the main class. Program will exit." 2007-11-18 04:16 P.M.

出現這個,原來是選錯了東西,windows--preferences--java--installed jres--這裡我選擇了jdk,應該是選擇jre的。

不知道對不對,我的是選擇這個就行了,我網上也找過了,找到了下面這個原文,不過我用了,好像沒有用。

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

February 20, 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 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.

Oh and by the way, 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

結果:按方案執行,現在用的是Eclipse3.3.2,將JRES改為原來開發時用的1.4,依然未成功。

2)"Eclipse中執行Ant出現Could not find the main class的問題及解 "

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

這種情況通常是發生在換了另一份 Eclipse 拷貝之後。之前一般都能正常在 Eclipse 中執行 Ant 指令碼,刪除了原來的 Eclipse 之後換了另一個拷貝或者是新版本,在其中執行 Ant 指令碼時快顯視窗出現以下錯誤:

---------------------------
Java Virtual Machine Launcher
---------------------------
Could not find the main class. Program will exit.
---------------------------
確定
---------------------------

這種錯誤對用過 Java 的人來說還是很明白,找不到 Ant 的主類嗎。不過說實話也困擾過我一段時間,也沒去深究。說開了,癥結就是 Eclipse 中的 ANT_HOME 指向不對。

解決辦法:Eclipse 中進入 Window->Preferences->Ant->Runtime,在Classpath 標籤頁,看到 Ant Home Entries 指向的目錄不對了(它仍然指向你上回的目錄,而這個目錄應該不存在了),你要做的就是改變 Ant Home 指向正確的目錄,點 Ant Home 按鈕,選擇 Ant Home 目錄,比如我用的 Eclipse 是 3.3.1 的,Ant Home 是 Eclipse 的外掛程式目錄下的 org.apache.ant_1.7.0.v200706080842。

現在可以再次在 Eclipse 中執行你的 Ant 指令碼,是不是能正常運行了啊。

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

結果:按照上述操作步驟執行,依然未成功。(解決思路是正確的)

最終解決:解決方案 與上述過程無異,Eclipse 中進入 Window->Preferences->Ant->Runtime,選擇ant的Jar包在自己的項目中兩個ant.jar和ant-。launcher.jar,點擊確定後,重新執行ant的XML指令碼成功。 在此對各位網友表示感謝。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.