简体   繁体   English

在jar中更新类,指定目录?

[英]Updating class in jar, specify directory?

I want to update a .class file in a jar. 我想更新jar中的.class文件。 The .class file is in a folder in the jar. .class文件位于jar中的文件夹中。 If I want to update it, do I need to specify the specific pathname where it's located? 如果我想更新它,我是否需要指定它所在的特定路径名?

Do I do: 我这样做:
jar uf myJar.jar myFolder/myClass.class jar uf myJar.jar myFolder / myClass.class

or just: 要不就:
jar uf myJar.jar myClass.class jar uf myJar.jar myClass.class

If I don't specify path, will it automatically find the .class and replace it? 如果我没有指定路径,它会自动找到.class并替换它吗? Or are jars allowed to have the same .class names within different directories? 或者是否允许jar在不同目录中具有相同的.class名称?

You need to be explicit. 你需要明确。 It's perfectly valid to have different classes with the same name in different packages. 在不同的包中使用相同名称的不同类是完全有效的。 eg 例如

com.example.package.A
com.example.package.subpackage.A

etc... 等等...

You need to provide the full path name to update the jar file 您需要提供完整路径名来更新jar文件

jar uf myJar.jar myFolder/myClass.class jar uf myJar.jar myFolder / myClass.class

And you can have same class files in different directories 并且您可以在不同的目录中具有相同的类文件

jar uf jar-file input - >因为你想要更新已经存在的文件,你必须指定文件夹结构。

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

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