I have a jar file that contains source code. How can I browse this source code in Eclipse?
At the moment, my Eclipse opens the jar file in a Text Editor, and it isn't that helpful.
When I look in the preferences "General" > "Editors" > "File Associations" I have no associations for *.jar
and if I look in the available "Editors" I can't find anyone that seem to be a good fit for jar files.
How can I browse the source code in a jar file using Eclipse? Is there any Editor I should configure for jar files?
Extract the jar in some source directory (it's a zip file), and create a project with this directory as source.
Or, if this source jar file contains the sources of a classes jar file that is used as a library in your Eclipse project, just right-click on this jar file, select "Properties", then "Java Source Attachment", then "External File", and select the source jar file. Then each time you browse a class from this classes jar file, Eclipse will automatically show you its source code.
If you have the jar added to a project's classpath, you can view its source by:
Referenced Libraries
in thePackage Explorer
viewYou need both the .class and .java file in the jar to view source, though.
If you have only the .java file, the class won't appear at all.
If you have only the .class file, the class will appear as bytecode.
Example:
If you want just to open jar o war files (and search or browse scripting code), install the Eclipse plugin called "Eclipse zip editor", from eclipse marketplace. Just in case it's the website to drag and drop to eclipse