How can i edit a .class file from a jar?

2020-05-07 06:26发布

问题:

I have a .jar file and I have decompiled it using Java Decompiler, I want to modify a .class file from the .jar and recompile it. I tried to use eclipse to copy the code but it has many imports so i can't recompile it int a .class file without the imports. Is there any other solution? Is there a better approach to this ?

回答1:

You should on the first hand prevent these type of Fixes and Changes. But if it required, you should have all the import class's code also in order to recompile the decompiled class, as they will be required at the time of compiling, but that might not be a feasible option.

The other approach you can use is a Class Editor, which let you edit directly a class file. Get It Here



回答2:

the import directive is "sugar syntax". The compiler adds the correct package to all class references.



标签: java eclipse jar