How to delete a class file in a .jar file and modify it using my own implementation

So, I have a third-party library which is a .jar file. There are several classes in this bank. The problem is that in one class there is one error in this .jar. I know this because I can decompile the jar file to look at the java code, which I'm sure this class is the source of the error in my program.

The idea is that I delete the class and replace it with my own class, but I do not know how to do this.

+9
java android jar decompiling
source share
3 answers

There are several ways to do this:

  1. Try using winrar. You can open your jar in it, examine the directory containing the class file. You can delete and add class files.

  2. If you do not want to use winrar, do this:

Remove the jar with this command

jar -xvf yourjar.jar

It will blow the can. Delete the old class file and add the updated class file

Recreate the jar using the following command

jar -cvf yourjar.jar exploderjar directory /

+10
source share
+1
source share

Create your own class in the same package as the source one, make sure your classes are in front of the 3rd party bank in the java classpath. This way you override the original version, the class loader will load your class.

0
source share

All Articles