0

I am writing a Java application and part of it involves zipping/unzipping folders with a password encrypted. The code I use in Java to run terminal commands is:

p = Runtime.getRuntime().exec(command);
p.waitFor();

When I choose to zip a particular folder, the terminal call is:

command = zip -P password -r encrypted.zip folderIWantToZip

When I choose to unzip a particular folder, the terminal call is:

command = unzip -P password encrypted.zip

I detect when a user enters a wrong password (when trying to unzip) if the p.waitFor() value is 1 and not 0.

I am testing my application on a Mac and it seems to be working fine. I am assuming that these terminal calls will work exactly the same on Linux machines as well and I should be getting the same result.

I was wondering what would be the equivalent terminal/command prompt commands on a Windows machine to zip and unzip folders with password encryption. I have heard that this is not possible on command prompt without downloading a third party software like 7zip. In this case, what would be the equivalent terminal commands using 7zip/some other equivalent third party software such that this application would work on Windows?

user3254893
  • 1,071
  • 2
  • 13
  • 14
  • It looks like the Java part of your question is irrelevant. You're asking "How can I create and extract a password-protected ZIP file from the command-line on Windows?" – user253751 Jan 22 '15 at 22:44
  • The Info-ZIP zip and unzip programs are available for Windows just as they are for many other platforms. – David Conrad Jan 22 '15 at 22:48
  • Alternatively, you could use [zip4j](http://www.lingala.net/zip4j/) which allows Java to read/write zip files encrypted with the [WinZip standard](http://www.winzip.com/aes_info.htm). – Elliott Frisch Jan 22 '15 at 22:53
  • Does zip4j allow you to encrypt password protected zip files? and unzip these? I have heard that it is not possible- http://stackoverflow.com/questions/15085249/how-to-encrypt-zip-file-using-zip4j – user3254893 Jan 26 '15 at 21:39

0 Answers0