How can I view the source code in a jar file containing the source code in Eclipse?

I have a jar file containing the source code. How to view source code in Eclipse?

At the moment, my Eclipse opens the jar file in a text editor, and this is not so useful.

When I look in the "General"> "Editors"> "File Associations" settings, I don’t have associations for *.jar , and if I look in the available "Editors", I can’t find anyone that seems to be suitable for jar files .

How can I view the source code in a jar file using Eclipse? Is there any editor I have to configure for jar files?

+4
source share
3 answers

Extract the jar into any source directory (this is a zip file) and create a project with this directory as a source.

Or, if this jar source file contains the sources of the class jar file that is used as the library in your Eclipse project, simply right-click this jar file, select Properties, then Java Source Application, then External File and select the source jar file. Then, each time you look at a class from this jar class file, Eclipse will automatically show you the source code.

+5
source

If you have a jar added to the project path, you can view its source:

  • Referenced Libraries Extension in Package Explorer View
  • Expand the jar that you are looking at
  • Double click on the .class file

You need .class and .java files in the bank to view the source.
If you only have a .java file, the class will not be displayed at all.
If you only have a .class file, the class will display as bytecode.

Example:

screenshot of eclipse with referenced jar expanded

+5
source

If you just want to open jar o war files (and search or browse script code), install the Eclipse plugin called "Eclipse zip editor" from the eclipse website. Just in case, this is a website to drag onto eclipse

enter image description here

0
source

Source: https://habr.com/ru/post/1380065/


All Articles