天天看點

Eclipse如何跳轉到Java系統類的源代碼

In Eclipse you want to navigate to the source code of standard class String, and you get the following message: Source not found

Eclipse如何跳轉到Java系統類的源代碼

Solution

(1) Install JDK in your laptop, and then configure it into Windows->Preferences->Java->Installed JRE. Delete existing entry for JRE:

Eclipse如何跳轉到Java系統類的源代碼
Eclipse如何跳轉到Java系統類的源代碼

And click Add… button:

Eclipse如何跳轉到Java系統類的源代碼

Add JDK instead:

Eclipse如何跳轉到Java系統類的源代碼

Once added, set JDK as default entry:

Eclipse如何跳轉到Java系統類的源代碼

(2) Preferences->Java Build Path, remove existing entry of JRE:

Eclipse如何跳轉到Java系統類的源代碼

Click Add Library button:

Eclipse如何跳轉到Java系統類的源代碼

Choose JDK instead:

Eclipse如何跳轉到Java系統類的源代碼

Once done, you can now navigate to the source code of standard class like String now.

繼續閱讀