这几天装了个新版本的eclipse3.3.2,但是javaDoc的提示总是出不来,显示说是有exception,上网搜索也没有找到解决方案,今天早上认真的查看了一下原因,同时到workspace下看了.log,由于自己电脑上装了好多版本的jdk,于是换了一下jre,发现如果用jdk1.4.2就可以出来, 于是对比了一下1.6和1.4的区别,发现1.6的rt.jar没有src.zip,原因是我装jdk和jre是分开的文件夹,于是拷贝src.zip到jre下,eclipse就可以找到这个文件,于是问题解决了。下面就是log的错误信息和解决方案
!ENTRY org.eclipse.jdt.core 4 1008 2008-04-09 08:48:08.737
!MESSAGE Cannot retrieve the attached javadoc for System [in System.class [in java.lang [in D:/Program Files/Java/jre1.6.0_05/lib/rt.jar]]]java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:742)
at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1060)
at org.eclipse.jdt.internal.core.BinaryMethod.getAttachedJavadoc(BinaryMethod.java:554)
at org.eclipse.jdt.ui.JavadocContentAccess.getHTMLContentReader(JavadocContentAccess.java:133)
at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:176)
at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:125)
at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102)
at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69)
at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)
解决方案,到eclipse的window->preference->java->installed JRES然后选中没有出提示tips的JRE,然后点击右边的edit,在JRE system libraries列表中选择选择rt.jar,然后点击右边的source attachment,然后在location path的右边选择external file里找到src.zip的路径,例如D:/Program Files/Java/jre1.6.0_05/src.zip,一路选择ok保存,问题就解决了。