【问题标题】:Replacing a class file inside a folder in a jar file替换jar文件中文件夹内的类文件
【发布时间】:2014-12-31 17:43:58
【问题描述】:

我在C:\ (xx.jar) 中有一个 jar 文件。我需要用放置在C:\ 的类文件(yfile.class)替换xx.jar 中的类文件(路径:com\sample\folder\xfile.class)。

请帮助我用 jar 外的另一个类文件替换 jar 中的一个类文件的命令。我正在努力指出目录结构。

我试过了,

jar uf C:\xx.jar C:\yfile.class

上述命令在xx.jar 中创建了一个new 文件夹C:\yfile.class 位于C:\ 中。但我希望文件位于xx.jar 中的com.sample.folder

请帮助。提前致谢!

【问题讨论】:

    标签: java class jar directory


    【解决方案1】:

    你不能,真的。 Jar 真的是用来打包一个准备好的文件夹。 我想这也是为什么 maven 等会创建一个构建文件夹,其中包含最终会出现在 jar/war/ear 文件中的所有内容。

    jar uf C:\xx.jar C:\yfile.class
    

    确实只是将文件添加到存档中。 在您归档的文件夹中,您可以使用一些 -C 指令,但仅此而已。假设你的 myfile.class 位于名为 C:\classes 的目录中,并且你从该文件夹中调用了 jar

    jar uf C:\xx.jar -C .. classes\file.class
    

    将文件夹 classes 添加到 jar 中,其中包含文件 myclass.class。

    亲切的问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-16
      • 1970-01-01
      • 2018-11-16
      • 1970-01-01
      • 1970-01-01
      • 2011-09-12
      • 1970-01-01
      • 2012-03-13
      相关资源
      最近更新 更多