Adding zip file to classpath or -Xbootclasspath on J9

Hi,
I'm trying to add a zip file containing javax classes (jscience-vm14.zip) to the classpath when running my program. I haven't had any problems adding jar files for instance, but I can't seem to have this zip file included so that it can be recognized by the jvm.
I've noticed in the installation document of the J9 that if you want to add javax classes it has to be put on the -Xbootclasspath. So I've tried including the zip file using -Xbootclasspath/p:path/to/zipfile/zipfile.zip and I've tried -Xbootclasspath/a:path/to/zipfile/zipfile.zip. I've also tried just including it in the classpath with no luck either. I keep getting a NoClassDefFoundError: javax.units.Unit which is part of the jscience package
Any ideas how to get the zip file included?
Kind regards
Simon

Hi,
Thank you for your answer!
I'm using SWT and here's the code:
lstBread.addListener (SWT.Selection, new Listener () {
               public void handleEvent (Event e) {
               System.out.println("Widget selected!");
It's working wtihout error on win32 platform. But there is no call on Windows Mobile 5.0 platform. It doesn't run and no exception is throwed on J9 console.
However, when i use the same way for event handling in SWT Button, there is no problem both on WM5 and win32 platform. It's executed as i want.
The code for SWT Button:
btnSView.addListener (SWT.Selection, new Listener () {
               public void handleEvent (Event e) {
     System.out.println("Widget selected!");     
I couldn't find the reason of that. Why doesn't the list#addListener run on WMobile?
Best Regards,
Ceyhun Hallac

Similar Messages

  • Problem adding zip files - is there a size limit?

    Is there a size limit on zip files that are uploaded to the system? I have tried to upload zip files (18Mb and 28Mb) this morning, and on both occasions not all of the zipped information is uploaded.
    Please could you let me know why only half of my files and folder names are being loaded.
    Thanks very much
    Kate

    I had this problem. Portal was installed here with the default
    storage settings on all of the tables, including
    WWDOC_DOCUMENT$. My upload would crash with NO ERRORS. I
    looked at the apache error_log file and saw just what I
    expected: that table was blown out becaus it had reached max
    extents. I moved that table to its own gigantic tablespace and
    sure enough, the load went through fine. You might also be
    interested in what you find in WWDOC_DOCUMENT$. Because even
    after a purge, I found that files that got partially loaded were
    still in that table, even though they weren't visible through
    the portal. So I deleted them, and freed up even more space.
    I'd recommend you move that document table to a separate
    tablespace that the DBA can manage separately, because it's not
    going to grow like a traditional transactional system, so it
    really doesn't belong in the same area.
    Hope this helps,
    Adrian Klingel
    Exaweb

  • Adding image to a zip file

    Hi all,
    I am trying to work out a servlet that creates an on-the-fly zip file. I am trying to add an image in this zip file and then I want to prompt user to download the created zip file. It is creating the zip file -it prompts the user and downloads the zip file... but when I open the downloaded zip file -the image is not found to be added in it. Please help, here is the code:
    package servlets;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.zip.*;
    import java.net.*;
    import java.util.*;
    public class CreateZipFile extends HttpServlet {
         byte b[] = new byte[300000];
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
         ZipOutputStream zout = null;
         ServletOutputStream out = null;
         ServletContext servletContext = null;
         HttpServletResponse res=null;
         public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              this.res=res;
              out=res.getOutputStream();
              servletContext=getServletContext();
              File f= new File(getServletContext().getRealPath(req.getContextPath()));
              String fs = System.getProperty("file.separator");
              addToZip_Image (f.getParentFile() + fs + ("images/thermorack.jpg"));
              System.out.println("ready");
              String zip = bout.toString();
              res.setContentType("application/zip");
              res.setHeader("Content-Disposition", "inline; filename=output_dd.zip;");
              System.out.println("finished");
              out.println(zip);
              out.flush();
         public void addToZip_Image(String img) throws ServletException, IOException
              System.out.println("image=" + img);
                   try {
                        FileInputStream input = new FileInputStream(img);
                        zout = new ZipOutputStream(new FileOutputStream(img));
                        zout.putNextEntry(new ZipEntry("image.jpg"));
                        int len;
                        while ((len = input.read(b)) > 0) {
                        zout.write(b, 0, len);
                        zout.closeEntry();
                        zout.close();
                        input.close();
                        System.out.println("closed");                    
                   } catch (Exception e) {
                        System.out.println("Exception occurred");
                        res.setContentType("text/html");
                        out.println("<html><head><title>Error</title></head>");
                        out.println("<body><b>");
                        out.println("An error has occured while processing "
                                  + "<br>");
                        out.println("Here is the exception: <br>" + e + "<br>");
                        e.printStackTrace(new PrintWriter(out));
                        out.println("</body>");
                        out.println("</html>");
    }

    You would need to purchase Stuffit Standard:
    http://my.smithmicro.com/mac/stuffit/index.html

  • CLASSPATH, Jar file or zip file visibility during compilation and  run time

    I am using jwsdp-1_0_01 with some success.
    However, making my *.jar or *.zip files
    visible during ant builds is not working.
    Setting a CLASSPATH environment
    variable (BTW: I on a Linux box) seems
    to have no effect. I'm using the ant build
    machinery found the JWSDP download
    jwsdp-1_0_01/docs/tutorial/examples/jaxrpc/
    and as long as I don't reference anything in
    mystuff.zip
    compilation succeeds and tomcat is happy
    to provide my service. How can I get ant
    and tomcat to see 'mystuff.zip' or 'foo.jar'
    or whatever.
    Note: I was able to get past these problems
    using jwsdp-1_0-ea1 but (sigh) nothing learned there
    seems to help here.
    -joe

    Hi joe
    I made changes to targets.xml (in jwsdp-1_0\docs\tutorial\examples\jaxrpc\common) to include my own jar files.
    To enable Tomcat to see the jar files when I install the service, I copied them into jwsdp-1_0\common\lib.
    Here is the modified targets.xml (from Windows):
    <target name="compile-server" depends="prepare" description="Compiles the server-side source code">
    <echo message="Compiling the server-side source code...." />
    <javac srcdir="src" destdir="${build}/shared"
    includes="net\agmodel\metsoap\*.java"
    excludes="net\agmodel\metsoap\*Client.java"
    classpath="C:/jwsdp-1_0/common/lib/genericbroker.jar:C:/jwsdp-1_0/common/lib/weatherdata.jar" />
    </target>
    <target name="compile-client" description="Compiles the client-side source code">
    <echo message="Compiling the client source code...." />
    <javac srcdir="src" destdir="${build}/client" classpath="${jwsdp-jars}:build/shared:build/client:C:\jwsdp-1_0\common\lib\genericbroker.jar:C:\jwsdp-1_0\common\lib\weatherdata.jar" includes="net/agmodel/metsoap/*Client.java" />
    </target>
    Hope this helps.
    Good luck
    Matthew

  • Adding a file into existing zip file

    I need a add a file into existing zip file. and write into printwriter.
    How to do it?
    Waiting for the reply.
    Thanks and Regards,
    Narayanan. G

    Narayanan.G wrote:
    I need a add a file into existing zip file.API: [ZipOutputStream#putNextEntry()|http://java.sun.com/javase/6/docs/api/java/util/zip/ZipOutputStream.html#putNextEntry%28java.util.zip.ZipEntry%29]
    Tutorial: [http://java.sun.com/developer/technicalArticles/Programming/compression/].
    and write into printwriter.Writing a zip file into printwriter? Huh? Please elaborate.

  • Adding Classes to the JAR File's Classpath

    Ques 1- Can I use the wildcard * symbol in Manifest file to add classes/othes jar files to the JAR File's Classpath.I have folder named - Lib . where there are many jar files.Now,do I have to add each jar file by- Class-Path: Lib/jar1-name Lib/jar2-name . Instead, can I do this- Class-Path: Lib/*.jar OR Class-Path: Lib/*.class
    RIDICULOUS....105 views has been made but YET NO ANSWER. Isn't there anybody who knows the answer.
    Edited by: Tanvir007 on Apr 30, 2008 2:21 AM

    Ques 1- Can I use the wildcard * symbol in Manifest file to add ... other jar files ...?No. You could, however, place all your needed JARs in JavaHome/jre1.x.x/lib/ext - if this is a way for you.
    Ques 2 ??
    RIDICULOUS....105 views has been made but YET NO ANSWER.What hindered you to test it yourself?
    And the things we don't know far exceed the things we know. Why do you wonder?
    Have a nice day
    J�rg

  • Adding a folder to a zip file

    How can I add a folder to a zip file. What I want is to create a txt file, which I place in a regular folder,  then place the regular folder in a zipped folder. They all (folder, file , and zip) need to be the same name also, so the directory would be as an example C:\Desktop > runner.zip > runner > runner.txt or something similar. So far I can create a zip file, and I can create a regular folder and place the txt document in the regular folder, but i cannot seem to be able to put the regular folder in the zip folder. I get an error saying: "LabVIEW:  An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @." It creates the zip file, and also the other folder with the txt file in it, but it wont put the regular folder in the zip file.
    Thanks ahead of time

    lvuser333 wrote:
    are you using the example file or the same code as the above screen shot? So i think my problem is I have been trying to addd the folder to a zip file I created, whereas I think that if I just zip up the folder that has the txt file in it, I will then have a zip file which contains a folder which contains the txt file, is this correct?
    I'm using the code in the screenshot (I whipped up the example quickly to see if I could get it to work, so it probably isn't the best or cleanest way to do it).
    [The example code from NI should work, but is probably more than you need].
    You zip files, but you tell the VI which folder within the zip file (i.e. relative to the zip file) you want them to go in.
    Just like how you might have a folder tree on your C drive
    animals
    ->mammals
    ---->four_legs
    -------->delicious
    -------->thinks_you_are_delicious
    ---->two_legs
    ->birds
    ---->can_fly
    ---->cannot_fly
    ->fish
    ---->salt_water
    ---->fresh_water
    You can have the same structure in the zip file.
    For instance a photo of a flathead (a type of salt water fish)..
    the file might be flathead.jpg with the path within the zip would be fish\salt_water\flathead.png
    on the other hand a tiger photo
    the file would be tiger.png but the path would be mammals\four_legs\thinks_you_are_delicious\tiger.p​ng

  • Classpath to .jars inside .zip files

    I had post something similar to this but this time it's another idea (and another problem) - so, this is not cross-posting.
    I have this .zip file with 25 .jar files, I want to use it in my Manifest file, but it seems that when the classes are in the .jars and the .jars are in a zip file they are not reached by the Classloader.
    #  Archive Libs.zip*
    commons-collections-3.1.jar
    commons-digester.jar
    commons-lang-2.0.jar
    commons-logging-1.0.3.jar
    commons-logging.jar
    commons-logging-api.jar
    commons-net-1.4.1.jar
    firebirdsql-full.jar
    formsrt.jar
    itext-1.3.1.jar
    jasperreports-1.3.1.jar
    jaybird-2.1.1.jar
    jaybird-full-2.1.1.jar
    jcommon-1.0.0-rc1.jar
    jdt-compiler.jar
    jfreechart-1.0.0-rc1.jar
    Lib.jar
    log4j-1.2.14.jar
    looks-1.3.1.jar
    mail.jar
    pop3.jar
    substance-lite.jar
    swingx-0.8.0.jar
    activation.jar
    commons-beanutils.jar12670124 10779634 25
    The file MANIFEST.MF
    Manifest-Version: 1.0
    Specification-Version: 3
    Implementation-Version: 0 2007
    Implementation-Title: SikGraf(Standard)
    Specification-Vendor: Kooky
    Created-By: Kooky
    Main-Class: com.sikgraf.main.Main
    SplashScreen-Image: com/sikgraf/imagens/siggraf.jpg
    Class-Path: . \SikGrafStandard.jar \C:/Kooky/SigGraf/Libs.zip[/code]
    Is is possible to do that? (.jars inside a zip) Or am I dreaming here?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You would have to write your own custom classloader to do this, which is what http://one-jar.sourceforge.net/ tries to do.

  • JWSC Task "Error in opening zip file"

    I'm having a problem with JWSC execution. Within this task I have JWS subtask and implementation java file of web service. I have also added the other java files from other packages that are used in the implementation java file. When JWSC does compilation it try to compile java files from other packages that I have added and I'm getting the following error:
    <i>
    error: error reading C:\Projects\gctss\universe\src\java\com\db\gct\ss\universe\mercury\session\AssetAdminService.java; error in opening zip file</i>
    I don't understand how it is relaetd to zip.
    Please help me to resolve this problem.

    J2se 5.0 dosen't like anything other than archives in the classpath. For example, if you put a file directly in the classpath, you will get that error. Hope it helps.

  • How to exreact multiple pdf files from a zip files from application server to presentation server

    Hello exprts,
    I am passing one pdf file and one text file to zip file in apllication server through my custom program and then downloading it using standard function module to my desktop. its working fine. Then I added  another pdf file to my zip file. But only single pdf file is getting download . So can you please help me regardiong this issue? 

    Dear Experts ,
    I finded out the way to extrcat pdf files in presentation server. But now my problem is that I am not able to add multiple pdf files in a zip file. When I am adding new pdf file then older one is not coming in read data set. So please kindly tell me how can I add multiple pdf file in my zip file and again I can get all the pdf files from here.

  • I am trying to import BPM Project.zip file into Oracle enterpriserepository

    I am trying to import BPM Project.zip file into Oracle enterpriserepository from admin tab.
    I am getting the following exception. please help if any one know the solution.
    Performing import...
    Import Failed: Error [100]: An unknown server-side error occurred. Please record stack trace (if available) and contact technical support.
    com.flashline.exception.LoggableException: trouble parsing file in import bundle: SampleWScall/activityGuide.agdl
         at com.flashline.cmee.openapi.service.subsystem.impexp.XMLTranslator.decode(XMLTranslator.java:157)
         at com.flashline.cmee.openapi.service.subsystem.impexp.ImportJob.doJob(ImportJob.java:74)
         at com.flashline.cmee.openapi.service.subsystem.impexp.AbstractJob.perform(AbstractJob.java:75)
         at com.flashline.cmee.openapi.service.subsystem.impexp.JobThread.run(JobThread.java:41)
    Audit results stored in:
    C:\Users\AVINAS~1.YEL\AppData\Local\Temp\import-4705112223687937017.log
    Audit for [Import job.] created on [2012-09-24 11:53:59 IST].
    2012-09-24 11:53:59 IST - Adding Import job with ID=[50403] to job queue.
    Thanks in Advance.

    Hi
    Why are you trying to import BPM zip file are you trying to configure the out of the box workflows?
    They are something that need to be deployed from the process admin on BPM.
    There would be the .exp file you would need as its BPM 10g that you would need to use.

  • Adding a file to an already created Archive throws error

    Hello Experts,
    In one of the WLST python scripts, we had a piece of code which was adding a file to an already created archive. Below is the code snippet:
    import zipfile
    try:
    conn='1.properties'
    fileName='/home/pbnagara/temp/Zip1.par'
    myZip = zipfile.ZipFile(fileName, mode='a')
    myZip.write(conn)
    myZip.close()
    except Exception:
    print 'Exception occurred while writing to Zip file: ' + fileName
    --> it makes use of the standard python module [zipfile] to add a file to the archive.
    This code has started failing [for some strange unknown reason] when we upgraded.
    The same script works fine in a standalone mode[using the system's default python packages] but fails only when run within WLST.
    Does WLST package a different set of zipfile libraries? Can anyone point out what might be going wrong here?

    I did get a reply from someone on the jfreechart forum, but need to ask more questions. This was his reply:
    Hi Allyson,
    You are trying to add a (subclass of) JFrame to a JPanel...that won't work, of course, and Java tells you so.
    You need to create a ChartPanel to display your chart. This is a subclass of JComponent, which you can happily add to a JPanel (or any other container).
    Regards,
    Dave Gilbert
    Here is the code for the method:
    private void LineChartFrame() {
    double[][] data = new double[][] {
    { 1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 7.0, 8.0 },
    { 5.0, 7.0, 6.0, 8.0, 4.0, 4.0, 2.0, 1.0 },
    { 4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 4.0, 3.0 }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset(data);
    // set the series names...
    String[] seriesNames = new String[] { "First", "Second", "Third" };
    dataset.setSeriesNames(seriesNames);
    // set the category names...
    String[] categories = new String[] { "Type 1", "Type 2", "Type 3", "Type 4", "Type 5", "Type 6", "Type 7", "Type 8" };
    dataset.setCategories(categories);
    // create the chart...
    chart = ChartFactory.createLineChart(
    "Line Chart Demo 1", // chart title
    "Category", // domain axis label
    "Value", // range axis label
    dataset, // data
    true, // include legend
    true, // tooltips
    false); // urls
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
    }And I tried this to add it to my panel:
    jPanel1.add(chartPanel, null);But I get this error:
    java.lang.NullPointerException
    ChartPanel is defined globally in this file.
    jPanel1 is my main panel that I want to add the chart to.
    I am putting my last duke dollar on this in the hopes that someone can help. Thanks.
    Allyson

  • Java.util.zip.ZipException error in opening zip file

    Hello all,
    We are using Sun Java System web server 6.1 SP2. When I tried to deploy an application, I received this message: "Posted content length of --- exceeds limit of --- " the -dashes are the size of the file actually.
    I then added an init-param to the web.xml specifying the maximum size.
    After doing that, I tried to deploy the war file using administration interface, but received a network tcp/ip error. I then deployed it using command line wdeploy command. It worked but the web server won't start up after the deployment. The following error messages are found in the log file. Any thoughts as to whats wrong here? Is there a bug in SP2?
    [22/Sep/2006:17:30:44] finer ( 5668): ContextConfig[search]: URI='/search', ResourcePath='/WEB-INF/sun-web-search.tld' [22/Sep/2006:17:30:44] finer ( 5668): ContextConfig[search]:
    tldConfigJar(/WEB-INF/sun-web-search.tld): java.util.zip.ZipException: error in opening zip file
    [22/Sep/2006:17:30:44] finer ( 5668): ContextConfig[search]: URI='/jstl-fmt', ResourcePath='/WEB-INF/fmt.tld' [22/Sep/2006:17:30:44] finer ( 5668): ContextConfig[search]: tldConfigJar(/WEB-INF/fmt.tld): java.util.zip.ZipException: error in opening zip file
    [22/Sep/2006:17:30:48] failure ( 5668): CORE4007: Internal error: Unexpected Java exception thrown (java.lang.NoClassDefFoundError: org/xml/sax/ext/Attributes2, org/xml/sax/ext/Attributes2), stack: java.lang.NoClassDefFoundError: org/xml/sax/ext/Attributes2 at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1717) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:983) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1431) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1301) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at org.apache.xerces.parsers.AbstractSAXParser.<init>(Unknown Source) at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source) at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source) at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source) at org.apache.catalina.util.xml.XmlMapper.readXml(XmlMapper.java:274) at org.apache.catalina.startup.ContextConfig.defaultConfig(ContextConfig.java:882) at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1004) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:257) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:155) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3752) at com.iplanet.ias.web.WebModule.start(WebModule.java:257) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133) at org.apache.catalina.core.StandardHost.start(StandardHost.java:652) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:355) at org.apache.catalina.startup.Embedded.start(Embedded.java:995) at com.iplanet.ias.web.WebContainer.start(WebContainer.java:431) at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:500) at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:161) [22/Sep/2006:17:30:48] failure ( 5668): CORE3186: Failed to set configuration

    ooks like you are running into bug: 4719677
    When you deploy a web application using the Administration Server from a
    remote machine, the maximum upload size by default is 10 MB. This can be
    changed by editing the
    install-root/bin/https/webapps/instance-app/WEB-INF/web.xml file. In the
    servlet webappdeploy, insert an init param named maxUploadSize with a
    value in bytes specifying the maximum upload size. Example:
    <init-param>
    <param-name>maxUploadSize</param-name>
    <param-value>90000000</param-value>
    </init-param>

  • Error while extracting zip file

    I am using the following code to extract zip files from jar file
    source = "zip/test.zip"
    destination = "c:\\"
    public void unzip(String source,String destination){
              try{
                   ZipInputStream in = new ZipInputStream( this.getClass().getResourceAsStream(source));
                   FileOutputStream fos = null;
                   ZipEntry ze = null;
                   File ff = null;
                   while ( (ze=in.getNextEntry() ) != null ){
                        System.out.println( "name=" + ze.getName() );
                        ff = new File( destination + ze.getName() );
                        if ( ze.isDirectory() ){
                             System.out.println("making "+ze.getName()+" dir ("+ ff.mkdirs() +")");
                        else{
                             fos = new FileOutputStream( ff );
                             byte[] buf = new byte[1024];
                             int len;
                             while ((len = in.read(buf)) > 0){
                                  fos.write(buf, 0, len);
                             fos.close();
                             System.out.println("wrote file "+ff.getPath()+" success=" + ff.exists() );
                   in.close();
              }catch(Exception e){
                   e.printStackTrace();
         }     But i found error in extracting zip file
    java.io.FileNotFoundException: C:\eclipse\.eclipseproduct (The system cannot find the path specified)
    I need some quick response on it.

    Nothing to do with the resource path....thats fine. Use the code below.....most likely this will fix it.......
    Added a check for directories that start with a ".".  The File utility probably thinks its a file, also added a try....check it does make the "." directories.........dont forget the dukes.
        ZipInputStream zis = null;
        FileOutputStream fos = null;
        try
          zis = new ZipInputStream( new FileInputStream( "C:\\your_path\\your_zipfile_or_jar.zip" ) );
          ZipEntry ze = null;
          File ff = null;
          while ( ( ze = zis.getNextEntry() ) != null )
            System.out.println( "name=" + ze.getName() );
            ff = new File( "C:\\your_path\\" + ze.getName() );
            if ( ze.isDirectory()  || ze.getName().startsWith("."))
              try{ System.out.println( "making " + ze.getName() + " dir (" + ff.mkdirs() + ")" ); }catch(Exception e2){}
            else
              fos = new FileOutputStream( ff );
              byte[] buf = new byte[1024];
              int len;
              while ( ( len = zis.read( buf ) ) > 0 )
                fos.write( buf, 0, len );
              fos.close();
              System.out.println( "wrote file " + ff.getPath() + " success=" + ff.exists() );
          zis.close();
        catch( Exception ex )
          ex.printStackTrace();
        finally
          try { zis.close(); }catch(Exception ex){}
          try { fos.close(); }catch(Exception ex){}
        }

  • Creating a zip file from the contents of a directory

    hi, I am having a problem as the title suggests with a zip fil creation...
    using the basic example zip.java i wished to edit it so it doesnt zip a file fro the current directory but rather a directory i inputted.
    It is able to read the first file then throws out the following error with the code below it:
    java.io.FileNotFoundException: test.jpg (The system cannot find the file specified)
    import java.io.*;
    import java.util.zip.*;
    public class Zip {
       static final int BUFFER = 2048;
       public static void main (String argv[]) {
          try
             BufferedInputStream origin = null;
             FileOutputStream dest = new FileOutputStream("C:/Documents and Settings/Phil/My Documents/My Pictures/Work/test.zip");
             CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
             ZipOutputStream out = new
               ZipOutputStream(new BufferedOutputStream(checksum));
             //out.setMethod(ZipOutputStream.DEFLATED);
             byte data[] = new byte[BUFFER];
             // get a list of files from current directory
             File f = new File("C:/Documents and Settings/Phil/My Documents/My Pictures/Work/");
             f.listFiles();
             String files[] = f.list();
             for (int i=0; i<files.length; i++)
                System.out.println("Adding: "+files);
    FileInputStream fi = new FileInputStream(files[i]);
    origin = new BufferedInputStream(fi, BUFFER);
    ZipEntry entry = new ZipEntry(files[i]);
    out.putNextEntry(entry);
    int count;
    while((count = origin.read(data, 0,
    BUFFER)) != -1)
    out.write(data, 0, count);
    origin.close();
    out.close();
    catch(Exception e)
    e.printStackTrace();
    After investigation i am lead to believe this is because the method returns an array of file and directory names only but not their path and the unqualified names would have therefore be defaulted to the current working directory. Something i understand if this is the case.
    So instead i used the File.listFiles() method to return an array
    of File objects, instead of an array of Strings as shown in the snippet of the changed code below (the changed code highlighted)...but arrived at another error on the second section of highlighted code meaning i cant compile. I cant understand why this is so!
    The error is: "cannot find symbol, Symbol: Contructor ZipEntry (Java.IO.file), location: class.java.util.zip.ZipEntry"
    File f = new File("C:/Documents and Settings/Phil/My Documents/My Pictures/Work/");
             **************File g[] = f.listFiles();***************
             **************String files[] = f.list();**************
             for (int i=0; i<g.length; i++)
                System.out.println("Adding: "+g);
    FileInputStream fi = new FileInputStream(g[i]);
    origin = new BufferedInputStream(fi, BUFFER);
    **************ZipEntry entry = new ZipEntry(g[i]);************
    out.putNextEntry(entry);
    int count;
    while((count = origin.read(data, 0,
    BUFFER)) != -1)
    out.write(data, 0, count);
    origin.close();
    out.close();
    Any help and thoughts most appreciated. Thank u in advance

    I'll admit i took 1 look at that reply an thought "thats stupid that wont work"...
    then a second look an though "actually, i should work i cant believe i didnt think of that"
    Anyways i tried it and it did work
    How are the duke dollars awarded, cos u should have them ordinary_guy
    cheers!

Maybe you are looking for

  • Access the selected values from grid

    I want to select vendor from the list.For this I have loaded vendor list in grid.How to get the value of selected vendor into variable ? For this I have used following code- Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As

  • How to prepare 2009 MacBook Pro for sale

    I am selling my MacBook Pro with OS X version 10. 5. 8.  And want to erase all my personal files and saved passwords from the computer. How do I do that? I'm not very tech savy either, so I would appreciate any help.

  • Updating my ipod touch version 5.0.1

    Hi, i want to update my ipod touch (4th gen) to 5.1.1 so connected my device to itunes and it asks me to update it so i chose download and update. when my download began, i noticed that it's 750mb, and my dsl is a little bit slow (downloading that la

  • Authorisation after formatting Pc

    How can get authorisation from itunes after having formatted my pc, when i cannot connect to the itunes store( i cannot play purchased tracks). Also i cannot update my ipod. can anybody help.

  • Is it possible to place Facebook games using Firefox? Everytime i try, they never completely load.

    I have recently changed my ISP, therefore, i know my computer is not the problem, although some of the settings may be. My new ISP, AOL, instructed me to use Firefox for playing Facebook games, and that has not worked either. Every time i have attemp