Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overwrite java class in jar

Tags:

java

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

However, this it's a CR1 version and there is a bug in the class that I would like my application to overwrite.

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

like image 410
Dejell Avatar asked Jan 10 '11 15:01

Dejell


2 Answers

JAR files are just ZIP files. Use a tool like WinZip to extract all the files from the JAR, replace the .class file with yours, recreate the ZIP file using e.g. WinZip, rename it to .jar, overwrite the original JAR file.

If you don't have the original source to the .class file you need to correct, then use a Java decompiler to produce .java source for the class. It will lack comments etc present in the original, but it will be sufficient to correct errors (e.g. incorrect null checking, as I had a few times in some products.)

like image 123
Adrian Smith Avatar answered Sep 22 '22 20:09

Adrian Smith


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

like image 41
Paul Avatar answered Sep 25 '22 20:09

Paul