public static Process openInConsole(@Nullable File workFolder,Map<String,String> envVars,String... args) throws IOException {
  String[] commands=args;
  String cmd=F.concat(Arrays.asList(args)," ");
  if (U.isWindows())   commands=F.asArray("cmd","/c",String.format("start %s",cmd));
  if (U.isMacOs())   commands=F.asArray("osascript","-e",String.format("tell application \"Terminal\" to do script \"%s\"",cmd));
  if (U.isUnix())   commands=F.asArray("xterm","-sl","1024","-geometry","200x50","-e",cmd);
  ProcessBuilder pb=new ProcessBuilder(commands);
  if (workFolder != null)   pb.directory(workFolder);
  if (envVars != null) {
    String sep=U.isWindows() ? ";" : ":";
    Map<String,String> goalVars=pb.environment();
    for (    Map.Entry<String,String> var : envVars.entrySet()) {
      String envVar=goalVars.get(var.getKey());
      if (envVar == null || envVar.isEmpty())       envVar=var.getValue();
 else       envVar+=sep + var.getValue();
      goalVars.put(var.getKey(),envVar);
    }
  }
  return pb.start();
}

public static Process openInConsole ( @ Nullable File workFolder , Map < String , String > envVars , String ... args ) throws IOException { String [ ] commands = args ; String cmd = F . concat ( Arrays . asList ( args ) , " " ) ; if ( U . isWindows ( ) ) commands = F . asArray ( "cmd" , "/c" , String . format ( "start %s" , cmd ) ) ; if ( U . isMacOs ( ) ) commands = F . asArray ( "osascript" , "-e" , String . format ( "tell application \"Terminal\" to do script \"%s\"" , cmd ) ) ; if ( U . isUnix ( ) ) commands = F . asArray ( "xterm" , "-sl" , "1024" , "-geometry" , "200x50" , "-e" , cmd ) ; ProcessBuilder pb = new ProcessBuilder ( commands ) ; if ( workFolder != null ) pb . directory ( workFolder ) ; if ( envVars != null ) { String sep = U . isWindows ( ) ? ";" : ":" ; Map < String , String > goalVars = pb . environment ( ) ; for ( Map . Entry < String , String > var : envVars . entrySet ( ) ) { String envVar = goalVars . get ( var . getKey ( ) ) ; if ( envVar == null || envVar . isEmpty ( ) ) envVar = var . getValue ( ) ; else envVar += sep + var . getValue ( ) ; goalVars . put ( var . getKey ( ) , envVar ) ; } } return pb . start ( ) ; }
run command in separated console .
