Jdgui Anti-compilation +javac compilation = Passive File modification code

Source: Internet
Author: User

Tags: blog http ar using SP Java file on 2014

First, we need to know that packaged Java programs are compiled bytecode files (*.class), which are loaded into the JVM at runtime.

If you want to replace a class, you just need to recompile the source code of that class and then replace the previous class file.

So what if there is no source code? This time we can use anti-compilation software to decompile the class file, anti-compilation software is more famous Jd-gui, can be downloaded from the official website to the latest version

I'm using jd-gui-0.3.6.windows here.

After downloading the class file or jar package into the Jd-gui window you can see the anti-compiled code ~nice, so the first step is done

The second step: we can copy the code, such as create a Xxx.java file in the class folder and copy the Xxx.class decompile code into it.

Step Three: We modify the code to save and compile it with Javac

Here's how to use Javac to compile Java files

In general, direct Javac + file path is possible, but if there are some dependencies you need to use the-classpath option.

Like we're here to compile a file named Importui.java, the directory format after unpacking the jar package is as follows:


Here you can see the Gmsimport folder is the place where the class file is stored, it is the classpath of this project, so you need to add this folder when compiling the file

We also saw 2 jar packages, and we need to write a different one for the jar package, for example, we are here to compile a Importui.java file (the current directory is here)

Javac-classpath D:\gmsimport;d:\gmsimport\datepicker-v0.99-2006.09.01.jar; Com\test\gmslic\importui.java

This compiles well, and the default path to the generated class file is the same directory as the Java file

Try the Java command to start it, also need to bring the-classpath option Oh ~

Java-classpath D:\gmsimport;d:\gmsimport\datepicker-v0.99-2006.09.01.jar; Com.test.gmslic.ImportUI

It's a modified effect, isn't it? Nice, we can replace the previous version with a package!

By the-classpath, the above can be shortened to-cp~.

Jdgui Anti-compilation +javac compilation = Passive File modification code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: