eclipse 如何从 jar 编辑 .class 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31115168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:43:34  来源:igfitidea点击:

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

javaeclipsejar

提问by cgab

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 ?

我有一个 .jar 文件,我已经使用 Java Decompiler 反编译了它,我想从 .jar 修改一个 .class 文件并重新编译它。我尝试使用 eclipse 来复制代码,但它有很多导入,因此我无法在没有导入的情况下将其重新编译为 .class 文件。还有其他解决方案吗?有没有更好的方法来解决这个问题?

采纳答案by Ankit Nigam

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

您可以使用的另一种方法是类编辑器,它可以让您直接编辑类文件。 在这里获取

回答by Sharon Ben Asher

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

导入指令是“糖语法”。编译器将正确的包添加到所有类引用中。