I have a jar file, and I need to edit a particular class and save it back into the jar file.
I tried different decompilers, but I'm not able to save back to the jar.
I tried Eclipse along with JADCLIPSE to decompile.
By using that, I can see the decompiled class file, but I'm unable to edit it.
Could anyone please help me to resolve this?
I use JD-GUI to decompile .jar's, this has an option to export all the decompiled classes. If the .jar you are decompiling has not been obfuscated etc this source should be re-compilable (otherwise you will need to go about it by bytecode editing).
Once you have extracted the classes, you need to ensure when you compile you compile with the
-CP parameter pointing at
.;MyJar.jar so that dependencies within the .jar can be found at compile.
After you have recompiled and have your new .class file/s, open the .jar with 7z and replace the old .class file/s with your new one. You can do this step with the command line jar tool but 7z makes it easier. Again if the jar was obfuscated and class files have identical names with only case sensitive differences you may need to use Linux to reinsert the .class file. (probably possible on Windows, but I've never looked into it too deeply).
I previously decompiled this Java program to add a commandline interface, you can probably find the link in the comments;