Code example for JarOutputStream

Methods: flushclose

0
        Manifest mf = jarFile.getManifest(); 
        Attributes attrs = mf.getMainAttributes();
        attrs.putValue("Class-Path", "file:/" + resPath + "/JarIndex/hyts_13.jar");
         
        File mainJar = new File(resources.getAbsolutePath() + "/JarIndex/main.jar");
        JarOutputStream jos = new JarOutputStream(new FileOutputStream(mainJar), mf);
        jos.flush();
        jos.close();
        assertTrue(mainJar.exists());
 
        URL[] urls = new URL[1];
        urls[0] = new URL("file:/" + resPath + "/JarIndex/main.jar");
        ucl = URLClassLoader.newInstance(urls, null);
        assertNotNull(Class.forName("Main2", true, ucl));
    } 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE