在 Eclipse 中附加一个 jar 的源 [英] Attach the Source in Eclipse of a jar

查看:22
本文介绍了在 Eclipse 中附加一个 jar 的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Eclipse 中添加了一个 Student.jar 到我的 Build Path 中 -

I added a Student.jar into my Build Path in my eclipse like this-

在项目上右键->BuildPath->Configure Build路径->库->添加外部罐

Right click on the project->BuildPath->Configure Build Path->Libraries->Add External Jars

Student.jar 文件中有一个名为StudentTest 的类.当我在 Eclipse 中调试代码时,我进入了 Student.jar 中的 StudentTest 类.

There is one class named StudentTest in Student.jar file. When I was debugging my code in eclipse, I stepped into that StudentTest class in the Student.jar.

在那次日食之后,我就这样-

And after that eclipse shows me like this-

JAR 文件 S:some_locationStudent.jar 没有源附件.您可以通过单击下面的附加源来附加源

The JAR file S:some_locationStudent.jar has no source attachment. You can attach the source by clicking Attach Source below

现在我不确定我应该如何在我的日食中附加源代码.从哪里来?任何人都可以一步一步地告诉我我需要做什么.

Now I am not sure how should I attach the source in my eclipse. And from where? Can anyone provide me step by step what I need to do.

更新:-我尝试解压缩 Student.jar 并得到 Student 文件夹.之后,我尝试将源指向 Student 文件夹 但我仍然无法正确查看该类以便正确调试它,它显示了与上述相同的行为.

Update:- I tried unzipping the Student.jar and I got Student folder. And after that I tried pointing the source to Student folder But still I am not able to see the class properly so that I can debug it properly, it shows the same above behavior.

推荐答案

.jar 文件通常只包含 .class 文件,而不包含编译它们的 .java 文件.这就是为什么 eclipse 会告诉您它不知道该类的源代码的原因.

A .jar file usually only contains the .class files, not the .java files they were compiled from. That's why eclipse is telling you it doesn't know the source code of that class.

将源代码附加"到 JAR 意味着告诉 eclipse 可以找到源代码的位置.当然,如果您不了解自己,该功能也没什么帮助.当然,您可以尝试使用谷歌搜索源代码(或检查您从何处获得 JAR 文件).

"Attaching" the source to a JAR means telling eclipse where the source code can be found. Of course, if you don't know yourself, that feature is of little help. Of course, you could try googling for the source code (or check wherever you got the JAR file from).

也就是说,您不一定需要源代码来调试.

That said, you don't necessarily need the source to debug.

这篇关于在 Eclipse 中附加一个 jar 的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆