Code example for Attributes

Methods: putValue

0
        Support_Resources.copyFile(resources, "JarIndex", "hyts_13.jar");
 
        JarFile jarFile = new JarFile(resources.getAbsolutePath() + "/JarIndex/hyts_11.jar");
        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));
    } 
 
}