Java compiler level does not match解決方案,compilermatch

來源:互聯網
上載者:User

Java compiler level does not match解決方案,compilermatch

從別的地方匯入一個項目的時候,經常會遇到eclipse/Myeclipse報Description  Resource Path Location Type Java compiler level does not match the version of the installed Java project facet.出現這個問題的原因是因為,eclipse/myeclipse的jdk編譯版本與出現問題的項目JDK編譯版本不一致所導致!

1、先設定好jdk,需要確定 項目,eclipse/myeclipse,系統 用的是同一個版本的JDK,例如系統中安裝的JDK是1.7,所以把eclipse的jdk成1.7

 

2、進入 windows---proferences---java--compiler設定編譯出來的檔案使用的格式是 1.7版本的 (設定成多少都行,只要相容,並且與你項目的編譯版本一直就可以,我這裡統一設定成1.7) 

3、進入項目--properties---java Compiler 把項目編譯版本也設定成 1.7 

4、進入項目--properties---Myeclipse---project Facets設定java檔案的版本為 1.7,並打勾。 

5、最後重新匯入一下工程檔案。

 

補充說明:

如果重新匯入工程後,無法發布deployed,檢查工程目錄下.setting檔案夾內的org.eclipse.wst.common.project.facet.core.xml設定檔

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="com.genuitec.runtime.generic.jee60"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="jst.web.jstl" version="1.2.1"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

修改完設定檔,重新匯入,重新發布。

 

相關錯誤處理:

Unsupported major.minor version 51.0解決辦法

錯誤原因:用jdk7編譯的class檔案放到基於jdk6運行在tomcat之中,就會報這個錯。

 解決方案:

開啟exclipse中項目上的屬性—java compiler–選擇一個合適的版本後重新編譯即可。

具體步驟

解決:項目------>右鍵------>屬性------>Java Compiler------>Compiler Compliance Level------>選擇你使用的JDK版本------>應用。

總結:不同的JDK版本使用的major.minor不同,所以會導致這個錯誤。在項目中要使用當前電腦配置的JDK版本,切忌張冠李戴。

知識擴充:major.minor version,它相當於一個軟體的主次版本號碼,只是在這裡是標識的一個Java Class的主要版本號和次版本號碼。

 

聯繫我們

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