The jar file XXX.jar has no source attachment 解决办法

今天做jar包的测试,遇到一个很头疼的问题。就是我的jar文件里的class不能反编译。

搞了一个小时,不是因为jad与eclipse版本不匹配,也不是因为网上的乱起八糟的原因。

先把官方的描述贴一下:

Invisible code from JARs
Sometimes control-clicking in the editor or single-stepping down through code, code for which the source is unknown to Eclipse is encountered. An edit window comes up with…

Class File Editor

Source not found

The jar file XxxxxYyyyy.jar has no source p_w_upload.
You can attach the source by clicking Attach Source below:

[Button: Attach Source]
To remedy this, click the Attach Source button to get the Source Attachment Configuration dialog. There, you click on one of three buttons to attach the source.

However, you are not really attaching source code (by .java extension), but looking for code associated with the JAR in question.

Source code and JARs
Some JARs come with source code and many do not. You have to pay attention to get the source code to, say, the Apache HTTP client code, otherwise you end up with only the binary JAR you need to link with. This is not usually a problem because you can consider that the supplier has done his job perfectly and if there’s an error or bug, it’s your own and usually you can determine the defugalty by your own means without that third-party source code.

(This foregoing discussion is incomplete because I’m not elaborating on where or how to get the source code to third-party JARs even though I’ve done it before. Maybe another time when I have to do it again.)

When adding JARs to the build path via right-clicking on a project, choosing Build Path->Configure Build Path…, and then clicking on Libraries, you can see, if you click to open a listedxxx.jar, Source p_w_upload:. Clicking, you’ll see you can Edit… the path: you fall into the same sequence as described for the Editor above.

Javadoc and JARs
This is a similar discussion as the preceding one for source p_w_uploads in Build Path. Edit the path to Javadoc location:. Instead of navigating to the project, you’ll be looking for anindex.html in the distribution. Choose its parent directory.

这算是什么解决方案啊?
最后我才意识到,可能是打jar包的时候,设置的问题。重新打jar并测试,果真能够查看源码。
解决办法:勾选Export Java source files and resources

你可能感兴趣的:(Java)