The jar file XxxxxYyyyy.jar has no source attachment 原创 wangyuelucky 2012-09-25 21:55:48 博主文章分类:Java ©著作权 文章标签 jar 文章分类 后端开发 ©著作权归作者所有:来自51CTO博客作者wangyuelucky的原创作品,请联系作者获取转载授权,否则将追究法律责任 今天做jar包的测试,遇到一个很egg疼的问题。就是我的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 将图片打包到jar中的路径问题 下一篇:java 读取配置文件或者图片文件,然后打jar包的问题 提问和评论都可以,用心的回复会被更多人看到 评论 发布评论 全部评论 () 最热 最新