Syntax error, type parameters are only available if source level is 1.5 報錯(轉)

當我的eclipse使用jdk1.6的時候,創建泛型類,系統會提示錯誤:

“Set project compiler compliance settings to '1.5'”

“Syntax error, type parameters are only available if source level is 1.5”

這時候需要改動兩個地方:

1.右擊項目-->properties-->java compiler -->選擇enabel project specific setting -->Compiler compliance level :選擇1.5版本,其他默認

2.右擊項目-->properties -->project facets-->將java後的下拉框選擇爲5.0

eclipse編譯Syntax error, parameterized types are only available if source level is 5.0

在myeclipse裏引入新項目的時候會報如下錯誤:

在使用泛型的地方提示:

Multiple markers at this line
- Syntax error, parameterized types are only available if source level
is 5.0
- The type List is not generic; it cannot be parameterized with
arguments <Application>

1)一種是Eclipse對所有項目默認的設置是5.0以下,項目繼承了默認設置(在Preferences/Java/Compiler裏改爲5.0或高於5.0)
另一種是項目裏設置了source level 5.0以下(在 項目屬性/Java Compiler 裏改爲5.0或高於5.0)

你的JDK 版本比較舊,或者你裝了比較新的版本,但是你在Eclipse中的設置有問題,編譯級別設置的不是比較新的版本的編譯器。
eclipse措無題詩如下:
Multiple markers at this line
- Syntax error, parameterized types are only available if source level
is 5.0
譯:語法錯誤 ,泛型只有在5.0以上的版本才支持
- The type List is not generic; it cannot be parameterized with
arguments <Application>
List 不是泛型,引起的原因還是編譯器不支持~~

解決辦法: 在Eclipse中,菜單條 ---"Windows" ----"preferneces"
在彈出對話框中 ,在左側列表框中 選擇 "JAVA" ---子菜單中 "compiler" ...
然後在右側把 "Compiler compliance level" 設置成5.0以上 即可。

發佈了14 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章