JD-GUI decompiles the jar package into Java source code

It is inevitable for programmers to learn from the code of other java projects. But sometimes you can only get .calss files, jar packages or war packages. At this time, programmers are required to be able to decompile these types of files into Java code and form a project that can be compiled and run. The decompilation tool introduced in this article is JD-GUI. The decompiled jar package is a jar package of a springboot project.

Decompilation tool use

After downloading JD-GUI, decompress it, no need to install, double-click to open the exe file.
JD-GUI decompiles the jar package into Java source code

Open file select the jar package to be decompiled,
JD-GUI decompiles the jar package into Java source code
open it, and the java source code file is in the classes->com directory on the left
JD-GUI decompiles the jar package into Java source code

Click the file you want to view, you can see the source code, click the underlined variable symbol, it will automatically jump to the definition place, you can also search for the variable name, but the search will be slower and you need to wait a while.

Get the source code

In this way, only the code can be viewed. To compile, modify, and run the code, all the codes must be extracted to form a project. Click File-> save all source
JD-GUI decompiles the jar package into Java source code
source code will be saved as a compressed
JD-GUI decompiles the jar package into Java source code
archive decompression are three folders
JD-GUI decompiles the jar package into Java source code
java code in BOOT-INF / calsses / com in
JD-GUI decompiles the jar package into Java source code
the copy with classes directory of all things to establish good empty springboot Compile and run in the project, and the directory hierarchy must be copied correctly.

Get the project configuration file

Copy the content in the project configuration file application.properties and pom.xm and paste the content in the file with the same name in the decompressed directory.

Get the jar package that the project depends on

Now the project code and configuration file are also available, but generally the project cannot be successfully run. Because the decompiled pom is not particularly accurate, there may be no import in the pom for the packages needed by many projects. Or some of the jar packages used in the original project were originally imported into the project manually, not managed by the pom.
The best way is to extract all jar packages that need to be imported from the decompiled jar packages.

Change the suffix of test01.jar to zip test01.zip and unzip it to the current folder.
JD-GUI decompiles the jar package into Java source code
The decompressed BOOT-INF\lib contains all the jar packages needed for this project, and all jar packages are added to the project by adding external jar.
JD-GUI decompiles the jar package into Java source code

Run the project

It is very close to successfully running the project here, because the decompiled code is not particularly accurate. Some codes need to be analyzed and modified manually, or the modification can only be commented out before the compilation can pass. Some packages may report errors during runtime, mainly because the package imported by pom conflicts with the package imported manually, or the version of some packages is incorrect, which needs to be resolved one by one. Of course, some decompiled projects can run correctly without reporting errors, which is of course the best.

Guess you like

Origin blog.51cto.com/14947900/2539855