简体   繁体   中英

How to include Java Source code within Eclipse?

In Netbeans, I can see the built-in sourse code of Java by clicking on LeftClick + Ctrl , and the .java file is shown:

在此处输入图片说明

But when I do the same thing in Eclipse, the following is shown:

在此处输入图片说明

How can include the source code within Eclipse? I need Java 7 source code if possible.

您是否尝试过下载源代码 ,然后在发布的屏幕快照中单击“附加源代码”按钮?

You could attach source manually, but the easier method would be to switch Eclipse to use the JDK instead of the JRE... in which case it will discover and attach the sources that came with the JDK for you.

You can do this by going to your Eclipse Preferences ( Window > Preferences ) then under Java > Installed JREs you can click the Search button. Point it to your c:\\Program Files\\Java and let her rip.

You'll then see all the installed JREs and JDKs in there. You can use the checkbox to set your workspace default to the preferred JDK. You can use the Java > Installed JREs > Execution Environments to ensure that when you have a project building against something like JavaSE-1.7 you force the correct Java installation (this is how m2e typically configures the classpath...).

Existing projects in your workspace (if they're setup to use an explicit JRE instead of an Execution environment or the workspace default) you may have to switch as well by right clicking on the JRE System Library and changing it to a configured Execution environment or JDK.

Clear as mud? :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM