We have program( written in VB ) using a call to a winzip program or 7zip command line tool to zip some files. Once I accidentally uninstall the winzip on my computer and making one of our program( created by the programmer already left ) crashed. So we cannot uninstall the winzip program.

Now we am writing another program with java + windows batch file. And I've come to a point which I need to make a decision between 1) using a call to external tool ( for example 7z ) for gzip in windows batch file, 2) or I make a java program to gzip the file.

Obviously a external tool such as 7z is convenient and we can avoid some extra coding with java. On the contrary, if 7z is uninstalled accidentally, our program will crash. What do you think?

  • 8
    You can and should package whatever tools you need with your app if their license allows doing so (and if it doesn't, find a tool that allows redistribution). That way there's no risk of the tools not being available to you at runtime.
    – Adam Lear
    Commented Mar 22, 2012 at 4:17
  • 1
    We have program using a call to a winzip program, we are using shell script. Which is it? The approach to take will be different for each.
    – StuperUser
    Commented Mar 22, 2012 at 13:31
  • 1
    its not 100% clear if your distributed software relies on winzip or just your build system?
    – jk.
    Commented Mar 22, 2012 at 14:13
  • @StuperUser I've elaborated the detail to avoid confusion. Thanks. Commented Mar 23, 2012 at 2:08

3 Answers 3


In the case of zipping capabilities in a Java program, you shouldn't need to delegate to an external program like winzip or 7zip. Have you looked into the standard Java zipping functionality? The ZipOutputStream in partcular should be able to do what you need. I haven't used it to create zips (or gzips) myself but I would expect it to be easier than calling an external program, especially when it comes to error handling.

  • Calling the external program is easier when we are using shell script. I am not going to call the external program in java. Commented Mar 22, 2012 at 6:09
  • Sorry I was thinking that your main program was written in Java... Not sure why I got so many up-votes if that is the case. Commented Mar 22, 2012 at 19:33
  • Still though, it can save you hassles to avoid reliance on 3rd party apps where you don't need to. For example, they may end up having incompatibilities with OS versions etc. Commented Mar 22, 2012 at 19:37

If your program crashes in the absence of 7zip, you have to add some very basic thing every program should have: it is called "error handling". For example, if 7zip is missing at the place where you expect it, your program could display an error message telling the user what went wrong and that you expect 7zip to be installed. And (as far as I known), current license of 7zip is mostly LGPL, so redistributing it (without modification) should be no probem (but IANAL).


To save your program from Crash, you have to add your necessary dll from that application. But i warn you that it should not break any liecense agreement

  • -1. He's not calling the DLL. He's calling the executable.
    – user16764
    Commented Mar 23, 2012 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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