guyeuro
V2EX  ›  问与答

jar -xvf 解压 jar 包后如何打包?

  •  
  •   guyeuro · Sep 5, 2017 · 2935 views
    This topic created in 3196 days ago, the information mentioned may be changed or developed.

    我用 jar -xvf 解压一个 jar 然后得到:

       BOOT-INF  META-INF  org
    

    我修改了 BOOT-INF 里的一个配置文件 现在想要将其打包回 jar 文件 如何操作?

    7 replies    2017-09-05 11:58:51 +08:00
    UnisandK
        1
    UnisandK  
       Sep 5, 2017
    我记得 jar 就是个 zip 包。。?
    yunkchen
        2
    yunkchen  
       Sep 5, 2017
    jar -uf name.jar BOOT-INF META-INF org
    guyeuro
        3
    guyeuro  
    OP
       Sep 5, 2017
    @yunkchen

    jar -uf my.jar BOOT-INF/ META-INF/ org/

    java.io.FileNotFoundException: my.jar (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at sun.tools.jar.Main.run(Main.java:261)
    at sun.tools.jar.Main.main(Main.java:1288)
    hcymk2
        4
    hcymk2  
       Sep 5, 2017
    jar --help .
    RTFM
    guyeuro
        5
    guyeuro  
    OP
       Sep 5, 2017
    @hcymk2

    用 jar cvfm my.jar META-INF/MANIFEST.MF BOOT-INF/ org
    成功打包了
    但是

    # ls META-INF
    MANIFEST.MF maven spring-configuration-metadata.json

    META-INF 目录下还有 maven spring-configuration-metadata.json
    有啥问题不
    Mithril
        6
    Mithril  
       Sep 5, 2017
    你要是就想修改一个破文件还不如直接拿 7zip 改完了再塞回去
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 22:46 · PVG 06:46 · LAX 15:46 · JFK 18:46
    ♥ Do have faith in what you're doing.