View the source code of the jar package.class file

Install the JD decompilation plugin

Sometimes you want to learn more about the source code of the jar package that the project depends on, or the compiled class file, but you find that ordinary text editors cannot open it, or

Use hold down Ctrl and click on the class name, the text editor to jump is as follows

Question 1:

How to know whether a jar package is open source
Question 2:

​ When editing a .java file, select a class name, such as the String class, and then press F3 to see the source java code (or hold down the ctrl key and click the class name to see it),

​ But some class names, you can't see the source code when you click on it, so how can I see the source java code at this time?

	The source attachment does not contain the source for the file String.class.
源附件不包含文件String.class的源。

    You can change the source attachment by clicking Change Attached Source below:
你可以通过点击下面的Change Attached Source来改变源附件。

When you configure it, the Attached Source is still the same after finding the jump,insert image description here

In the editor below it there is gibberish like this

insert image description here

No way, I can't view the compiled source code

So the tutorial begins

Download the JD plugin

Enter JD official website http://jd.benow.ca/, slide down the page to see JD-Eclipse as follows, download Release jd-eclipse-site-1.0.0-RC2.zip

Java Decompiler (java-decompiler.github.io)

insert image description here

click download

insert image description here

insert image description here

Install 2.0.0Installation

Download JD-Eclipse ZIP file,
Launch Eclipse,
Click on “Help > Install New Software…”,
Drag and drop ZIP file on dialog windows,
Check “Java Decompiler Eclipse Plug-in”,
Click on “Next” and “Finish” buttons,
A warning dialog windows appear because “org.jd.ide.eclipse.plugin_x.y.z.jar” is not signed. Click on “Install anyway” button.

  • Download the JD-Eclipse ZIP file.
  • Start Eclipse.
  • Click "Help > Install New Software...".
  • Drag and drop the ZIP file to the dialog window.
  • Check "Java Decompiler Eclipse Plug-in".
  • Click the "Next" and "Finish" buttons.
  • A warning dialog window appears because "org.jd.ide.eclipse.plugin_x.yzjar" is not signed. Click the "Install anyway" button.

Version 2.0 is easier to install than version 1.0

Here is the 1.0.0 method for 2.0.0 installation

Install version 1.0.0 official website information

The installation process is clearly written on the official website, as shown in the red box above, so I can barely understand it and force a translation:
Installation

  1. Download and unzip the JD-Eclipse Update Site,//Download the file, and then...no need to unzip! (forced translation, don’t, don’t, don’t need to decompress) (unzip actually means unzip, the blogger can use it directly without decompression, then don’t, don’t, don’t need to decompress)

  2. Launch Eclipse, // run Eclipse

  3. Click on “Help > Install New Software…”, //Click on the Eclipse menu bar Help >

  4. Install New Software…

  5. Click on button “Add…” to add an new repository,//点击Add…

  6. Enter “JD-Eclipse Update Site” and select the local site directory,//输入Name:JD-Eclipse Update Site;Location:

    Select the path of the jd-eclipse-site-1.0.0-RC2.zip you just downloaded

  7. Check “Java Decompiler Eclipse Plug-in”,//选中Java Decompiler Eclipse Plug-in

  8. Next, next, next... and restart Eclipse.//Next, next all the way, and finally restart Eclipse, get it done


Use 1.0.0 installation steps to install 2.0.0Edition

graphic operation

Action

I believe you are jumping directly to this graphic operation

Eclipse menu bar Help > Install New Software...

insert image description here

Name: Fill in freely, Location: Select the jd-eclipse-site-1.0.0-RC2.zip file path you just downloaded –> It is recommended that Name fill in the downloaded installation class name jd-eclipse-2.0.0or javaDecompile

prepared for obsessive-compulsive disorder patients

insert image description here
next step next

insert image description here

This Warning appears, don’t worry, just OK

Select Install anyway

Restsrt cannot be displayed

The problem is the default text editor

After restarting Eclipse, the class file still cannot be displayed?
Then set an indescribable setting in Eclipse, set the JD viewer as the default class file viewer

1. Click on the Eclipse menu bar Window > Preference > General > Editors > File Associations

2. Select ".class" and ".class without source" respectively, then select the JD Class File Viewer below, and then click Default to set it as the default

(Note: If you do not find the relevant option, click "Add" in the upper right corner to add it)


Add default class file viewer

insert image description here

class without source, that is, no external Attached Source was configured before

insert image description here

In addition: the configuration of JD-Eclilpse is hereinsert image description here

insert image description here

Finally you're done –> there is another method JAD method

Guess you like

Origin blog.csdn.net/m0_53870075/article/details/124850112
Recommended