How do you extract a JAR in a UNIX filesystem with a single command and specify its target directory using the JAR command?

前端 未结 4 675
囚心锁ツ
囚心锁ツ 2020-12-23 16:34

I am creating a Python script within which I am executing UNIX system commands. I have a war archive named Binaries.war which is within an ear archive named Portal.ear

4条回答
  •  一个人的身影
    2020-12-23 17:11

    If your jar file already has an absolute pathname as shown, it is particularly easy:

    cd /where/you/want/it; jar xf /path/to/jarfile.jar
    

    That is, you have the shell executed by Python change directory for you and then run the extraction.

    If your jar file does not already have an absolute pathname, then you have to convert the relative name to absolute (by prefixing it with the path of the current directory) so that jar can find it after the change of directory.

    The only issues left to worry about are things like blanks in the path names.

提交回复
热议问题