Overwrite java class in jar

I have a class called org.jbpm.task.Comment in my jbpm.jar.

However, this is version CR1, and there is an error in the class that I would like my application to be rewritten.

Is it good to have a class in my project under com.jbpm.task called Comment, and everywhere, even in other jars, it will refer to mine?

+4
source share
4 answers

JAR files are only ZIP files. Use a tool such as WinZip to extract all files from the JAR, replace the .class file with your own, recreate the ZIP file, for example, WinZip, rename it to .jar, overwrite the original JAR file.

If you do not have the source source in the .class file, you need to fix it and then use the Java decompiler to create the .java source for the class. There are no comments in the original, etc., But this is enough to correct errors (for example, incorrect check of zero, since several products are used in some products).

+5
source

I would suggest using a Zip utility like 7zip to open the jar file and replace the class in the jar file with the last.

+2
source

Well, behavior is not guaranteed. Because of this, I had a bad experience. Check the lower thread SO. If you are targeting a different implementation of the JVM, this may be a problem.

Xerces behave differently on SUN JRE v1.5 and IBM J9 v1.5

+1
source

You will need to make sure your jar is loaded before bpm.jar. In some JREs, banks are in one place, loaded in alphabetical order.

0
source

Source: https://habr.com/ru/post/1334942/


All Articles