0 Preface
For some historical legacy projects that do not provide source code, or third-party jar packages, we often need to open them, but there is no source code. At this time, we need to decompile to obtain the project source code.
Of course, not all jars can be decompiled, some of which have been anti-compiled, but it is completely feasible to decompile the projects left over from our history
Today we will take a look at how to decompile
1. Decompile via JD-GUI
JD-GUI is an open source decompilation software, through which we can decompile the jar package more conveniently.
1. The download address is as follows
2. After the download is complete, unzip the compressed package
3. Here I take the mac system as an example, double-click to open JD-GUI
the program in the decompressed folder
The new version of m1 chip mac may report the following error
The content of the prompt describes that jdk1.8 or above is required. In fact, this is not the reason. I am using jdk11 here. To solve this problem, a file needs to be modified
2. Right click JD-GUI
and click显示包内容
3. Enter Contents/MacOS
the folder, open universalJavaApplicationStub.sh
the file, and replace it with a new version of the file. The content of the new version of the file can be copied at the following address
Because it is an external network address, some students may have problems accessing it, so I separately put the modified software package in the network disk address shown below, and can be downloaded directly if necessary
JD-GUI mac modified version network disk download address
Extraction code: vkcs
4. Double-click to open the software, and drag the jar package to be decompiled to the software interface
5. Select all files, click File-Save All Sources
to save the decompiled source code, and select the save path
6. Wait for the decompilation to complete
7. After the decompilation is completed, BOOT-INF/classes
you can see the generated source code under the folder
So we get the source code we want, simple and fast! Of course, the generated source code will have some deviations in the folder structure, you only need to manually adjust it, and the core source code can be completely captured.