eclipse中无法查看java中方法的源代码

某一天,我想查看nath方法的源码,发现按下ctrl+shift+T后,输入math

发现显示为:

The JAR file C:\Program File\Java\jre7\lib\rt.jar has no source attachment.You can attach the source by clicking Attach Source below

解决方法如下:

1.点 “window“-> “Preferences”-> “Java” -> “Installed JRES”;


2.此时"Installed JRES"右边是列表窗格,列出了系统中的JRE 环境,选择你的JRE,然后点边上的“Edit...“, 会出现一个窗口(Edit JRE) ;
3.选中rt.jar文件的这一项:“D:\Javase\jre8\lib\rt.jar” 点 左边的“+”号展开它(JDK实际安装路径以你的为准);


4.展开后,可以看到“Source Attachment:(none)”,点这一项,点右边的按钮“Source Attachment...“,选择你的JDK目录下的 “src.zip”文件;
5.选择apply and close即可

最后就可以解决了

猜你喜欢

转载自blog.csdn.net/rngweskt/article/details/82847058