Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to copy a file into a ZIP or JAR archive.

Is that possible? If so how?

share|improve this question
up vote 6 down vote accepted

Use -m to import a file to a ZIP archive.

I found this on StackOverflow maybe it helps you.
How to move a file in to zip uncompressed, with zip cmd tool

But be careful it deletes the source file after it adds it to the archive. See the link for more details.


Instructions from this site.
-m moves the specified files into the ZIP archive; actually, this deletes the target directories/files after making the specified ZIP archive.

If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without errors. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.

zip -m yourfile zip.file

share|improve this answer
i tried cp -m q.txt !!!**not working – moata_u Mar 7 '11 at 9:51 are the man ...THANKS :::)))) – moata_u Mar 7 '11 at 10:03

**for jar extension you can use jar command as the following :

jar -uf file.jar newFile

**OR you can extract file from jar extension as following :

jar -xf file.jar fileToBeExtract 

Have Fun :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.