Code example for JarEntry

        // name>/xx.jar 
        att.put(Attributes.Name.CLASS_PATH, ".." + File.separator
                + barJar.getParentFile().getName() + File.separator
                + barJar.getName());
        joutFoo = new JarOutputStream(new FileOutputStream(fooJar), man);
        joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class"));
        joutFoo.write(getResource(resources, "hyts_Foo.ser"));
        // execute the JAR and read the result 
        assertTrue("Error executing JAR",
                execAndGetOutput(builder).startsWith( "FOOBAR"));
     * tests case when Main-Class is not in the jar launched but in another jar 
     * referenced by Class-Path 
     * @throws Exception in case of troubles 
    public void test_main_class_in_another_jar() throws Exception { 
Connect your IDE to all the code out there  Get Codota for Java