简体   繁体   English

如何在netbeans的jar文件中进行更改?

[英]How to make changes in a jar file in netbeans?

I am having a jar file. 我有一个jar文件。 It contains .class and .java files. 它包含.class和.java文件。 I need to make changes in the jar file and those changes should be reflected in the .class file. 我需要在jar文件中进行更改,这些更改应反映在.class文件中。 Is there any way to do the same. 有没有办法做同样的事情。 I am using Netbeans 8.0. 我正在使用Netbeans 8.0。 I am not getting any correct way after searching a lot. 经过大量搜索后,我没有任何正确的方法。 Please help me with a solution. 请帮我解决。

You cannot just "edit" a class file (within a jar or not). 您不能只是“编辑”一个类文件(是否在jar中)。 At least not in a useful manner. 至少没有以有用的方式。 You would have to recompile the class. 您将不得不重新编译该类。 You could replace the class file in the jar, but that can easily lead to problems (a coworker of mine once replaced a file in a jar which then didnt work at all anymore). 可以替换jar中的类文件,但是很容易导致问题(我的同事曾经替换过jar中的文件,然后再也无法使用了)。

It's better to just repackage your jar. 最好只是重新包装您的罐子。 If it takes you more than 2 clicks or one command line call to clean, compile and package your project, you're doing it in an unnecessary hard way. 如果您需要2次以上的点击或一次命令行调用来清理,编译和打包项目,那么您的工作就不必要了。

Using your IDE, or some build tool like ant or maven (both can do more than just build) it shouldn't be much of a problem for you to edit your java file and recompile and package the project. 使用您的IDE或诸如ant或maven之类的某些构建工具(不仅可以进行构建,还可以做更多事情),对于您编辑Java文件并重新编译和打包项目来说,这不是什么大问题。

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

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