如何替换jar文件中的类文件? [英] How can I replace a class file in jar files?

查看:1031
本文介绍了如何替换jar文件中的类文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一位同事写了一堂课。他的班级用我的班级。他没有告诉JVM我的类在每次编译类时都存在于哪里,而是将这两个类打包成一个jar文件,我可以这样运行: java -jar hisclass.jar

A coworker of mine wrote a class. His class uses my class. Rather than tell the JVM where my class lives every time his class is compiled, he packaged both classes into a jar file that I can run like so: java -jar hisclass.jar

现在我决定改变我的班级。因此,由于我的课程被预编译到他的jar中,他的课程(我仍然需要使用)使用我的旧课程。我的同事离开了,我不知道他是如何将所有东西打包成一个jar文件供我使用。

Now I have decided to make changes to my class. Therefore, since my class was precompiled into his jar, his class (which I still need to use) uses my old class. My coworker left, and I don't know how he packaged everything into a jar file for me to use.

现在,当我尝试 java时-jar hisclass.jar ,当他的类调用我的类时,它调用我的类的旧版本产生错误,因为我的类的旧版本不再正常工作。任何人都可以帮助我将他的类重新编译成jar或只更新我的那个吗?

Now, when I try java -jar hisclass.jar, when his class calls my class, it calls an old version of my class which produces an error, as that old version of my class no longer works correctly. Could anyone help me recompile his class into a jar or just update the one I have?

推荐答案

在Eclipse中我认为应该是足以将您的代码导出为jar文件。

In Eclipse i think it should be enough to export your code as jar file.

http://viralpatel.net/blogs/create-jar-file-in-java-eclipse/

所以基本上你得到旧的jar,解压缩,在eclipse中作为项目加载并导出为jar文件。
你已经完成了。

So basically you get the old jar, extract, load as project in eclipse and export as jar file. And you're done.

这篇关于如何替换jar文件中的类文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆