Override methods in jar packages Classes in jar packages

Preface

Not much, simple and clear.

Two ways to rewrite jar

The first

Rewrite steps:

1. Find the class of the method you want to override and check the path;

2. Create a new class with the same package name and the same name in our src directory;

3. Copy all the code of the class where the overridden method is located in the jar package to our newly created class with the same package name and the same name;

4. Modify the code in the corresponding method in our newly created class with the same package name and same name. Be careful not to change the parameters in the method, and do not delete the existing methods in the original class, but you can add some new methods
. .

principle:

When compiling and outputting, the classes under our src will be used first instead of the classes in the Jar package. This achieves the purpose of overriding the jar package method.

The second type

This method can be used without affecting the project directory structure:

Steps 1-4 are the same as steps 1-4 in the first method.

5. Rewrite the classes with the same package name and the same name, and compile the .java file into a .class file.

6. Create a new folder on the desktop and save the compiled .class file there.

7. Open the file directory where the jar package is located.
Insert image description here
6. Use compression software to preview the class files in the jar package.
I use Bandzip
Insert image description here
. 7. Delete the classes that need to be replaced in the jar package (the original files in the jar) and compile yourself. Copy the .class file into it.
XV6aTY2OQ==,size_16,color_FFFFFF,t_70)
8. Replace
Insert image description here
9. Delete the newly created packages and classes in our src directory.

Guess you like

Origin blog.csdn.net/uziuzi669/article/details/117155090