简体   繁体   English

Java编辑Jar文件

[英]Java Edit Jar File

I have a jar file which includes seviral classes. 我有一个包含seviral类的jar文件。 In that jar there is a Confirmation.class file which i want to edit. 在那个罐子里,有一个我要编辑的Confirmation.class文件。 I decompiled that class by usin JAD. 我用JAD对该类进行了反编译。 Then i edit it with notepad++ and saved as .java file. 然后,我用记事本++编辑它并保存为.java文件。

Now how can i create my new jar file with other classes? 现在如何与其他类一起创建新的jar文件?

Other files format is .class but mine is .java, is it problem? 其他文件格式是.class,而我的文件格式是.java,这有问题吗?

If it is , how can i compile my .java class ? 如果是,我该如何编译我的.java类? (when i use command javac Confirmation.java it gives errors and want other classes) (当我使用命令javac Confirmation.java时,它给出错误并需要其他类)

Thanks.. 谢谢..

Do you have dependencies to other jars? 您对其他罐子有依赖性吗?

If this is the case, you will have to put them on the compiler classpath in advance. 如果是这种情况,则必须事先将它们放在编译器的类路径中。

In any case, just decompile all the package (I use jd-gui), change the class, compile, open the original jar as a zip, put the new class on it, and you are done. 无论如何,只需反编译所有包(我使用jd-gui),更改类,编译,将原始jar作为zip打开,将新类放到上面就可以了。

Another approach is to create dummy classes for the missing dependencies... 另一种方法是为缺少的依赖项创建虚拟类。

Personally, I really discourage this approach of "reverse engineering" working with an already compiled package, but I understand situations where you don't have access to the original source code, but you need to fix something urgently (ex: working in a company, where your code comes from an external provider on the other side of the planet...) 就我个人而言,我确实不鼓励使用已编译的程序包进行“逆向工程”的方法,但是我了解到您无法访问原始源代码,但需要紧急解决的情况(例如:在一家公司工作) ,您的代码来自地球另一端的外部提供商...)

You may try to copy & paste the code in Java IDE such as Eclipse , NetBeans , etc and ask the IRC to compile for u. 您可以尝试在EclipseNetBeans等Java IDE中复制并粘贴代码,然后要求IRC为您编译。 Have a nice day :) 祝你今天愉快 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM