m2e (maven eclipse) 在運行一些命令時出現了無法compile(Unable to locate the Javac Compiler in:)

來源:互聯網
上載者:User

出現的bug提示

Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_07\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.

從上面的Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required)

可以看出m2e要求用於編譯應該要用jdk且jdk是1.4及以上的版本才行

我在命令列下echo %JAVA_HOME%

檢查了一下我的"JAVA_HOME"是C:\Program Files\Java\jdk1.6.0_20

那是哪裡出錯了呢,,這時我意識到我用的是m2e,那麼我的運行時環境應該就是根據

eclipse(eclipse也有預設也有自己的運行時環境)指定的才是,,那麼我只要把修改eclipse指定的運行時環境路徑不就可以了,

於是

1、在eclipse裡面修改 "window-->preferences->java->installed jres" :

edit the selected jre or add a new jre and select it  

the location should be "C:\Program Files\Java\jdk1.6.0_20\jre"

please don't close the "Edit JRE" dialog ,continue the second step.

2、remove the default jre system libraries and add all the jar in  the lib folder, lib subdirectory in  %JAVA_HOME%/jdk**/jre/

illustration:

 

_^^_.......I wish this bug report message will help u....and please comment this ...

 

 

 

 

在用maven的這些日子以來,發現還有一種可能出現這種錯誤,就是你已經install了你的項目,,這時出現這種bug時,你需到倉庫去把這些已存在的版本刪除即可

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.