Extracting jar to specified directory

前端 未结 7 487
庸人自扰
庸人自扰 2021-01-31 06:58

I wanted to extract one of my jars to specified directory using jar command line utility.

If I understand this right -C option should to the tr

7条回答
  •  遇见更好的自我
    2021-01-31 07:22

    In case you don't want to change your current working directory, it might be easier to run extract command in a subshell like this.

    mkdir -p "/path/to/target-dir"
    (cd "/path/to/target-dir" && exec jar -xf "/path/to/your/war-file.war")
    

    You can then execute this script from any working directory.

    [ Thanks to David Schmitt for the subshell trick ]

提交回复
热议问题