Code example for Manifest

Methods: getMainAttributes

0
    /** 
     * This test does quite the same as test_execCreatedJar, but includes a manifest. 
     * Note however that the Dalvik JAR format does not require this manifest. 
     * We just test whether the manifest is placed correctly within the JAR by 
     * dumping its contents read as a simple text resource. 
     * No! We can't do that so easily either, as there are other (parent) JARs 
     * with a manifest inside, taken with precedence. 
     * So we will reopen the JAR as a JarFile and check the manifest 
     *  with a top level end-to-end approach. 
     */ 
    public void test_execCreatedJarWithManifest () throws IOException, InterruptedException { 
        File jarFile = File.createTempFile("cts_dalvikExecTest_", ".jar");
        jarFile.deleteOnExit();
 
        // Create the manifest: 
        Manifest manifest = new Manifest();
        Attributes attrs = manifest.getMainAttributes();
        attrs.put(Attributes.Name.MANIFEST_VERSION, "3.1415962");
        attrs.put(Attributes.Name.MAIN_CLASS, "dalvikExecTest.HelloWorld");
        attrs.put(Attributes.Name.CLASS_PATH, jarFile.getName());