Eclipse “cannot be resolved to a type” error

來源:互聯網
上載者:User
http://chenxiaohu612.blog.163.com/blog/static/192214286201171004911955/

 http://zhaoningbo.iteye.com/blog/1137215

 

引言: 

    eclipse新匯入的項目經常可以看到“XX cannot be resolved to a type”的報錯資訊。本文將做以簡單總結。 

本文: 

    (1)jdk不匹配(或不存在) 

    項目指定的jdk為“jdk1.6.0_18”,而當前eclipse使用的是“jdk1.6.0_22”。需要在BuildPath | Libraries,中做簡單調整。 

    (2)jar包缺失或衝突 

    當找不到“XX”所在的jar包時,會報這個錯。解決只需要找到(ctrl+點擊,可能能看到jar包名稱)對應jar包匯入項目即可。 

    另外,出現相同的XX時也會報此錯。可能需要調包、解包、選刪。 

    (3)eclipse尋找項目類型策略所致 

    eclipse下,上述兩條都對比過了,沒有任何問題,可偏偏還報這錯。這時,需要操作一下 Project | Clean... ,問題即可解決。原因是,機制所致。因為某些特殊原因,eclipse沒能自動編譯原始碼到build/classes(或其他classes目錄),導致類型尋找不到。 

Based on the comments here, I started checking how I could make sure that my Ant build 

wouldn’t interfere with my Eclipse build.

I found an option in Eclipse that clears up the problem (and is possibly more efficient than

 changing the 2 build system’s output folders).

Windows–>Preferences–>Java–>Compiler–>Building–>Output folder–>

”Rebuild class files modified by others”. This exists in Eclipse 3.5; I’m not sure about earlier versions.

Checking this seems to have fixed my problems.

 

相關文章

聯繫我們

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