koolvcvc
koolvcvc

Reputation: 11

Standard Java jar decompiling ,modifying and compiling again

I am new to java. I am trying to decompile the standard jar file(adall.jar) from where I am trying to load my custom jar.

I am able to decompile jar and also able to make the code changes. but when I try to compile it back it could not compile due to some error, these errors occurs due to stripped or replaced variable name.

I tried Krakatau, JD-Core and Procyon but unable to recompile back and create a jar. using Krakatau I was able to introduce the code but that did not worked successfully. have anybody tried similar thing?

Upvotes: 1

Views: 1041

Answers (1)

Robert
Robert

Reputation: 42585

You don't need to decompile and recompile the whole JAR file with all it's class files. It is often better to pick only one class file which is used by other classes and has not many and not very complex methods. That increases the chance decompiling and recompiling works without problems.

When recompiling the one Java file you can add the original JAR file to the class path, so any dependencies to other classes do not prevent recompiling.

When you have recompiled the one class you can replace the one .class file and overwrite the original .class file in the original JAR file by the recompiled one. Common ZIP tools like 7-Zip can do this easily.

Upvotes: 0

Related Questions