Attach the Source in Eclipse of a jar

前端 未结 11 1574
清歌不尽
清歌不尽 2020-11-28 06:46

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

Right click on the project->BuildPath->Configure Build P

相关标签:
11条回答
  • 2020-11-28 07:24

    I am using project is not Spring or spring boot based application. I have multiple subprojects and they are nested one within another. The answers shown here supports on first level of subproject. If I added another sub project for source code attachement, it is not allowing me saying folder already exists error.

    Looks like eclipse is out dated IDE. I am using the latest version of Eclipse version 2015-2019. It is killing all my time.

    My intension is run the application in debug mode navigate through the sub projects which are added as external dependencies (non modifiable).

    0 讨论(0)
  • 2020-11-28 07:27
    1. Download JDEclipse from http://java-decompiler.github.io/
    2. Follow the installation steps
    3. If you still didn't find the source, right click on the jar file and select "Attach Library Source" option from the project folder, as you can see below.

    Drop down option location

    0 讨论(0)
  • 2020-11-28 07:30

    Use Java Source Attacher !

    It does what eclipse should do - a right click context menu that says "Attach Java Source.

    enter image description here

    It automatically downloads the source for you and attaches it. I've only hit a couple libraries it doesn't know about and when that happens it lets you contribute the url back to the community so no one else will have a problem with that library.

    0 讨论(0)
  • 2020-11-28 07:31

    Go back in to where you added the jar. I believe its the libraries tab, I don't have Eclipse open but that sounds right. to the left of the jar file you added there should be an arrow pointing right, click that and 3 or 4 options expand, one of them being the source file of the library. Click on that and click edit(I think you can also double click it) then locate the file or folder on your hard disk, you probably have to click apply or okay and you're good to go, same with javadoc and i think the last one is native libraries. I don't pay much attention when I'm in there anymore if you couldn't tell. That's what you were asking, right?

    0 讨论(0)
  • 2020-11-28 07:32

    Simply import the package of the required source class in your code from jar.

    You can find jar's sub packages in

    Eclipse -- YourProject --> Referenced libraries --> yourJars --> Packages --> Clases

    Like-- I was troubling with the mysql connector jar issue "the source attachment does not contain the source" by giving the path of source folder it display this statement

    The source attachment does not contain the source for the file StatementImpl.class
    

    Then I just import the package of mysql connector jar which contain the required class:

    import com.mysql.jdbc.*;
    

    Then program is working fine.

    0 讨论(0)
  • 2020-11-28 07:34

    I Know it is pretty late but it will be helpful for the other user, as we can do Job using three ways... as below
    1)1. Atttach your source code using
    i.e, Right click on the project then properties --> Java build path--> attach your source in the source tab or you can remove jar file and attach the source in the libraries tab
    2. Using eclipse source Analyzer
    In the eclipse market you can download the plugin java source analyzer which is used to attach the open source jar file's source code. we can achieve it after installing the plugin, by right click on the open source jar and select the attach source option.
    3. Using Jadclipse in eclipse you can do it
    last not the least, you can achieve the decompile your code using this plugin. it is similar way you can download the plugin from the eclipse market place and install in your eclipse. in jadclipse view you can see your .class file to decomplile source format note here you cannot see the comment and hidden things

    I think in your scenario you can use the option one and option three, I prefer option three only if i want to the source code not for the debug the code. else i ll code the option 1, as i have the source already available with.

    0 讨论(0)
提交回复
热议问题