如何正确修补 JAR 文件中的 Java 类?
我需要修补 JA 文件中的一个类,该文件位于格式为 pack1.pack2.pack3.com 的包中。所以类的全名是:
pack1.pack2.pack3.com.classtopatch
我的应用程序中有一个文件夹:
c:/app/patches
我应该简单地将类复制到 c:/app/patches/classtopath.class 文件还是我 需要创建整个文件夹树,例如:
c:/app/patches/pack1/pack2/pack3/com
并在 pack1/pack2/pack3/com 中放置 classtopath.clas ? 谢谢。
I need to patch a class that is in a JA file, in a package following the form pack1.pack2.pack3.com. So the full name of class is:
pack1.pack2.pack3.com.classtopatch
I have a folder in my application:
c:/app/patches
Should I simply copy the class to c:/app/patches/classtopath.class file or do I
need to create the entire folder tree like:
c:/app/patches/pack1/pack2/pack3/com
and in pack1/pack2/pack3/com put classtopath.clas ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您需要创建目录结构以匹配您的包名称。
创建
c:/app/patches/pack1/pack2/pack3/com
并将classtopath.class
放入其中。Yes, you need to create the directory structure to match your package name.
Create
c:/app/patches/pack1/pack2/pack3/com
and putclasstopath.class
in it.您的问题不太清楚,但如果文件系统上有类文件,那么它们应该位于适当的包结构中。
如果将其打包到 jar 文件中,则 jar 文件本身可以位于任何位置,但包结构应该存在于 jar 文件中。
Your question isn't really clear, but if you've got class files on the file system, then they should be in the appropriate package structure.
If you're packing it into a jar file then the jar file itself can be anywhere, but the package structure should be present in the jar file.