public void writeJarFromContent(final String className,final String content,final OutputStream outStream) throws IOException {
  JarOutputStream jarOutputStream=new JarOutputStream(outStream);
  String formattedName=className;
  if (!formattedName.endsWith(".class")) {
    formattedName=formattedName.concat(".class");
  }
  if (className.contains("/")) {
    JarEntry entry=new JarEntry(className.substring(0,className.lastIndexOf('/')));
    entry.setTime(System.currentTimeMillis());
    jarOutputStream.putNextEntry(entry);
  }
  JarEntry entry=new JarEntry(formattedName);
  entry.setTime(System.currentTimeMillis());
  jarOutputStream.putNextEntry(entry);
  jarOutputStream.write(compileClass(className,content));
  jarOutputStream.closeEntry();
  jarOutputStream.close();
}

public void writeJarFromContent ( final String className , final String content , final OutputStream outStream ) throws IOException { JarOutputStream jarOutputStream = new JarOutputStream ( outStream ) ; String formattedName = className ; if ( ! formattedName . endsWith ( ".class" ) ) { formattedName = formattedName . concat ( ".class" ) ; } if ( className . contains ( "/" ) ) { JarEntry entry = new JarEntry ( className . substring ( 0 , className . lastIndexOf ( '/' ) ) ) ; entry . setTime ( System . currentTimeMillis ( ) ) ; jarOutputStream . putNextEntry ( entry ) ; } JarEntry entry = new JarEntry ( formattedName ) ; entry . setTime ( System . currentTimeMillis ( ) ) ; jarOutputStream . putNextEntry ( entry ) ; jarOutputStream . write ( compileClass ( className , content ) ) ; jarOutputStream . closeEntry ( ) ; jarOutputStream . close ( ) ; }
write a jar with a class of the given name with the provided content . the classname may have a package separated by / . for example : my / package / myclass
