public synchronized boolean run(String args[]){
  ok=true;
  if (!parseArgs(args)) {
    return false;
  }
  try {
    if (cflag || uflag) {
      if (fname != null) {
        zname=fname.replace(File.separatorChar,'/');
        if (zname.startsWith("./")) {
          zname=zname.substring(2);
        }
      }
    }
    if (cflag) {
      Manifest manifest=null;
      InputStream in=null;
      if (!Mflag) {
        if (mname != null) {
          in=new FileInputStream(mname);
          manifest=new Manifest(new BufferedInputStream(in));
        }
 else {
          manifest=new Manifest();
        }
        addVersion(manifest);
        addCreatedBy(manifest);
        if (isAmbiguousMainClass(manifest)) {
          if (in != null) {
            in.close();
          }
          return false;
        }
        if (ename != null) {
          addMainClass(manifest,ename);
        }
      }
      expand(null,files,false);
      OutputStream out;
      if (fname != null) {
        out=new FileOutputStream(fname);
      }
 else {
        out=new FileOutputStream(FileDescriptor.out);
        if (vflag) {
          vflag=false;
        }
      }
      File tmpfile=null;
      final OutputStream finalout=out;
      final String tmpbase=(fname == null) ? "tmpjar" : fname.substring(fname.indexOf(File.separatorChar) + 1);
      if (nflag) {
        tmpfile=createTemporaryFile(tmpbase,".jar");
        out=new FileOutputStream(tmpfile);
      }
      create(new BufferedOutputStream(out,4096),manifest);
      if (in != null) {
        in.close();
      }
      out.close();
      if (nflag) {
        JarFile jarFile=null;
        File packFile=null;
        JarOutputStream jos=null;
        try {
          Packer packer=Pack200.newPacker();
          Map<String,String> p=packer.properties();
          p.put(Packer.EFFORT,"1");
          jarFile=new JarFile(tmpfile.getCanonicalPath());
          packFile=createTemporaryFile(tmpbase,".pack");
          out=new FileOutputStream(packFile);
          packer.pack(jarFile,out);
          jos=new JarOutputStream(finalout);
          Unpacker unpacker=Pack200.newUnpacker();
          unpacker.unpack(packFile,jos);
        }
 catch (        IOException ioe) {
          fatalError(ioe);
        }
 finally {
          if (jarFile != null) {
            jarFile.close();
          }
          if (out != null) {
            out.close();
          }
          if (jos != null) {
            jos.close();
          }
          if (tmpfile != null && tmpfile.exists()) {
            tmpfile.delete();
          }
          if (packFile != null && packFile.exists()) {
            packFile.delete();
          }
        }
      }
    }
 else     if (uflag) {
      File inputFile=null, tmpFile=null;
      FileInputStream in;
      FileOutputStream out;
      if (fname != null) {
        inputFile=new File(fname);
        tmpFile=createTempFileInSameDirectoryAs(inputFile);
        in=new FileInputStream(inputFile);
        out=new FileOutputStream(tmpFile);
      }
 else {
        in=new FileInputStream(FileDescriptor.in);
        out=new FileOutputStream(FileDescriptor.out);
        vflag=false;
      }
      InputStream manifest=(!Mflag && (mname != null)) ? (new FileInputStream(mname)) : null;
      expand(null,files,true);
      boolean updateOk=update(in,new BufferedOutputStream(out),manifest,null);
      if (ok) {
        ok=updateOk;
      }
      in.close();
      out.close();
      if (manifest != null) {
        manifest.close();
      }
      if (ok && fname != null) {
        inputFile.delete();
        if (!tmpFile.renameTo(inputFile)) {
          tmpFile.delete();
          throw new IOException(getMsg("error.write.file"));
        }
        tmpFile.delete();
      }
    }
 else     if (tflag) {
      replaceFSC(files);
      if (fname != null) {
        list(fname,files);
      }
 else {
        InputStream in=new FileInputStream(FileDescriptor.in);
        try {
          list(new BufferedInputStream(in),files);
        }
  finally {
          in.close();
        }
      }
    }
 else     if (xflag) {
      replaceFSC(files);
      if (fname != null && files != null) {
        extract(fname,files);
      }
 else {
        InputStream in=(fname == null) ? new FileInputStream(FileDescriptor.in) : new FileInputStream(fname);
        try {
          extract(new BufferedInputStream(in),files);
        }
  finally {
          in.close();
        }
      }
    }
 else     if (iflag) {
      genIndex(rootjar,files);
    }
  }
 catch (  IOException e) {
    fatalError(e);
    ok=false;
  }
catch (  Error ee) {
    ee.printStackTrace();
    ok=false;
  }
catch (  Throwable t) {
    t.printStackTrace();
    ok=false;
  }
  out.flush();
  err.flush();
  return ok;
}

public synchronized boolean run ( String args [ ] ) { ok = true ; if ( ! parseArgs ( args ) ) { return false ; } try { if ( cflag || uflag ) { if ( fname != null ) { zname = fname . replace ( File . separatorChar , '/' ) ; if ( zname . startsWith ( "./" ) ) { zname = zname . substring ( 2 ) ; } } } if ( cflag ) { Manifest manifest = null ; InputStream in = null ; if ( ! Mflag ) { if ( mname != null ) { in = new FileInputStream ( mname ) ; manifest = new Manifest ( new BufferedInputStream ( in ) ) ; } else { manifest = new Manifest ( ) ; } addVersion ( manifest ) ; addCreatedBy ( manifest ) ; if ( isAmbiguousMainClass ( manifest ) ) { if ( in != null ) { in . close ( ) ; } return false ; } if ( ename != null ) { addMainClass ( manifest , ename ) ; } } expand ( null , files , false ) ; OutputStream out ; if ( fname != null ) { out = new FileOutputStream ( fname ) ; } else { out = new FileOutputStream ( FileDescriptor . out ) ; if ( vflag ) { vflag = false ; } } File tmpfile = null ; final OutputStream finalout = out ; final String tmpbase = ( fname == null ) ? "tmpjar" : fname . substring ( fname . indexOf ( File . separatorChar ) + 1 ) ; if ( nflag ) { tmpfile = createTemporaryFile ( tmpbase , ".jar" ) ; out = new FileOutputStream ( tmpfile ) ; } create ( new BufferedOutputStream ( out , 4096 ) , manifest ) ; if ( in != null ) { in . close ( ) ; } out . close ( ) ; if ( nflag ) { JarFile jarFile = null ; File packFile = null ; JarOutputStream jos = null ; try { Packer packer = Pack200 . newPacker ( ) ; Map < String , String > p = packer . properties ( ) ; p . put ( Packer . EFFORT , "1" ) ; jarFile = new JarFile ( tmpfile . getCanonicalPath ( ) ) ; packFile = createTemporaryFile ( tmpbase , ".pack" ) ; out = new FileOutputStream ( packFile ) ; packer . pack ( jarFile , out ) ; jos = new JarOutputStream ( finalout ) ; Unpacker unpacker = Pack200 . newUnpacker ( ) ; unpacker . unpack ( packFile , jos ) ; } catch ( IOException ioe ) { fatalError ( ioe ) ; } finally { if ( jarFile != null ) { jarFile . close ( ) ; } if ( out != null ) { out . close ( ) ; } if ( jos != null ) { jos . close ( ) ; } if ( tmpfile != null && tmpfile . exists ( ) ) { tmpfile . delete ( ) ; } if ( packFile != null && packFile . exists ( ) ) { packFile . delete ( ) ; } } } } else if ( uflag ) { File inputFile = null , tmpFile = null ; FileInputStream in ; FileOutputStream out ; if ( fname != null ) { inputFile = new File ( fname ) ; tmpFile = createTempFileInSameDirectoryAs ( inputFile ) ; in = new FileInputStream ( inputFile ) ; out = new FileOutputStream ( tmpFile ) ; } else { in = new FileInputStream ( FileDescriptor . in ) ; out = new FileOutputStream ( FileDescriptor . out ) ; vflag = false ; } InputStream manifest = ( ! Mflag && ( mname != null ) ) ? ( new FileInputStream ( mname ) ) : null ; expand ( null , files , true ) ; boolean updateOk = update ( in , new BufferedOutputStream ( out ) , manifest , null ) ; if ( ok ) { ok = updateOk ; } in . close ( ) ; out . close ( ) ; if ( manifest != null ) { manifest . close ( ) ; } if ( ok && fname != null ) { inputFile . delete ( ) ; if ( ! tmpFile . renameTo ( inputFile ) ) { tmpFile . delete ( ) ; throw new IOException ( getMsg ( "error.write.file" ) ) ; } tmpFile . delete ( ) ; } } else if ( tflag ) { replaceFSC ( files ) ; if ( fname != null ) { list ( fname , files ) ; } else { InputStream in = new FileInputStream ( FileDescriptor . in ) ; try { list ( new BufferedInputStream ( in ) , files ) ; } finally { in . close ( ) ; } } } else if ( xflag ) { replaceFSC ( files ) ; if ( fname != null && files != null ) { extract ( fname , files ) ; } else { InputStream in = ( fname == null ) ? new FileInputStream ( FileDescriptor . in ) : new FileInputStream ( fname ) ; try { extract ( new BufferedInputStream ( in ) , files ) ; } finally { in . close ( ) ; } } } else if ( iflag ) { genIndex ( rootjar , files ) ; } } catch ( IOException e ) { fatalError ( e ) ; ok = false ; } catch ( Error ee ) { ee . printStackTrace ( ) ; ok = false ; } catch ( Throwable t ) { t . printStackTrace ( ) ; ok = false ; } out . flush ( ) ; err . flush ( ) ; return ok ; }
starts main program with the specified arguments .
