3 Replies Latest reply: Apr 9, 2007 4:51 PM by 796447 RSS

    How to extract JAR file in particular directory

    807599
      Hi,

      I am extracting a JAR file(A.jar) in a Makefile

      Now the path of the Makefile is say /home/developer/

      The location of the JAR file is in /opt/tools/mk/A.jar

      I am extracting the jar file as:

      jar xvf /opt/tools/mk/A.jar

      This creates a directory named "A" under /home/developer, since the location of the Makefile is at /home/developer.

      Question) How do I unjar /opt/tools/mk/A.jar under /opt/tools/mk/ itself, irrespective of the location of the Makefile?

      thanks
        • 1. Re: How to extract JAR file in particular directory
          796447
          jar -?
          Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] files ...
          Options:
              -c  create new archive
              -t  list table of contents for archive
              -x  extract named (or all) files from archive
              -u  update existing archive
              -v  generate verbose output on standard output
              -f  specify archive file name
              -m  include manifest information from specified manifest file
              -0  store only; use no ZIP compression
              -M  do not create a manifest file for the entries
              -i  generate index information for the specified jar files
              -C  change to the specified directory and include the following file
          I'd say you may want to try the -C option
          • 2. Re: How to extract JAR file in particular directory
            807599
            Hi,

            This command is not working??

            jar xvf /opt/tools/mk/A.jar C /opt/tools/mk/

            Any idea on how to make this work?

            Thanks
            • 3. Re: How to extract JAR file in particular directory
              796447
              Hi,

              This command is not working??

              jar xvf /opt/tools/mk/A.jar C /opt/tools/mk/

              Any idea on how to make this work?

              Thanks
              Do you not see the dash (-) character as part of that option in the help text I displayed?

              sigh
              jar xvf -C /opt/tools/mk A.jar
              NOTE: Not tested by me. The key is to read the help description, and EXPERIMENT with it yourself.