Java - 如何编辑类文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38214462/
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
Java - How can I edit a class file
提问by Raz Razman
I have a self extracting exe file, if I open that file with 7-zip inside it I can see a bunch of java class files.
我有一个自解压 exe 文件,如果我用 7-zip 打开该文件,我可以看到一堆 java 类文件。
I need to make a simple change, if I open the class file in notepad, although it is a binary mess the change I need to make is an ascii value which is readbale in the text editor, if I edit the file, change it and update the archive, the application will no longer run. (Guess it sees the file as corrupted now)
我需要做一个简单的改变,如果我在记事本中打开类文件,虽然它是一个二进制混乱,但我需要做的改变是一个 ascii 值,它在文本编辑器中是可读取的,如果我编辑文件,改变它和更新存档,应用程序将不再运行。(猜猜它现在看到文件已损坏)
How can I edit this file and put it back in the archive? Can I decompile the single class file, recompile it and put it back into the archive?
如何编辑此文件并将其放回存档中?我可以反编译单个类文件,重新编译它并将其放回存档中吗?
采纳答案by Raz Razman
Okay figured it out.
好吧想通了。
java Class editor is a small program they may work for basic files.
java 类编辑器是一个小程序,它们可以用于基本文件。
However I found this better way:
但是我发现了这个更好的方法:
browse to the exe in 7-zip, right click and select "view inside" Browse to the folder containing the class file. Extract the class file to your pc. Open the class file with "Dirty Joe Java overall Editor" make the changes you need and be sure to click file/save./ Copy the file back into 7-zip and you have a working exe with the modification you just made. No need to decompile!
浏览到 7-zip 中的 exe,右键单击并选择“查看内部”浏览到包含类文件的文件夹。将类文件解压缩到您的电脑。使用“Dirty Joe Java整体编辑器”打开类文件进行您需要的更改,并确保单击文件/保存。/将文件复制回7-zip,您将拥有一个包含您刚刚所做修改的工作exe。无需反编译!
回答by Ivantha
No you can't. I think what you have to do is,
不,你不能。我认为你必须做的是,
1) Extract the class files to somewhere.
1) 将类文件解压缩到某处。
2) Decompile everything.
2)反编译一切。
3) Make your change.
3) 做出改变。
4) Recompile all the java file.
4)重新编译所有的java文件。
5) Make a new self extracting archive.
5) 制作一个新的自解压存档。
*You can use a site like this to decompile
http://www.javadecompilers.com/
*您可以使用这样的站点来反编译
http://www.javadecompilers.com/