3 Replies Latest reply: Nov 3, 2008 7:11 AM by 807589 RSS

    How to make self extracting zip file for java application

      Hi All,

      I have developed a java application.
      It requires some folders to exist like ex:

      Till now I am making zip file out of them and extracting to the C:\ folder manually.

      I am trying to automate this procedure... So if I give zip file, all the required folders should be created
      automatically and files will be copied to those locations.
      It should not ask the user for the folder location and should be routed automaticaaly to folders as i have shown above.

      So how can i implement this?
      Please let me know any free tools available to use for this purpose?

      Thank you ...

        • 2. Re: How to make self extracting zip file for java application

          I was trying to use those APIs, but getting the exception that "The system cannot find the path specified".
          I have given the path of zip file also along with the name ...

          Pasting the example code here for your reference:
          import java.io.*;
          import java.util.zip.ZipInputStream;
          import java.util.zip.ZipEntry;
          public class UnzipDemo {
              public static void main(String[] args) {
                  String zipname = "C:\\Eclipse_Workspace\\Test\\data.zip";
                  try {
                      FileInputStream fis = new FileInputStream(zipname);
                      ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
                      ZipEntry entry;
                      // Read each entry from the ZipInputStream until no more entry found
                      // indicated by a null return value of the getNextEntry() method.
                      while ((entry = zis.getNextEntry()) != null) {
                          System.out.println("Unzipping: " + entry.getName());
                          int size;
                          byte[] buffer = new byte[2048];
                          FileOutputStream fos = new FileOutputStream(entry.getName());
                          BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length);
                          while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
                              bos.write(buffer, 0, size);
                  } catch (IOException e) {
          And one more thing is that, how to ensure that files will be moved C:\productName\bin, C:\productName\lib ... every time I unzip the files...

          Please try to help me...

          Thanks again
          • 3. Re: How to make self extracting zip file for java application
            If any one faced similar problem, please respond here....

            Thanks to all