Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Is that possible? If so how?

share|improve this question

2 Answers 2

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.

UPDATE

Instructions from this site. http://linux.about.com/od/commands/l/blcmdl1_zip.htm.
-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 archive.zip !!!**not working –  moata_u Mar 7 '11 at 9:51
    
WOWOW...you 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

 
discard

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.