우분투 콘솔 명령하기 자바소스

import java.awt.Robot;
import java.awt.Window;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.ConsoleHandler;

import org.xml.sax.InputSource;

public class MainClass {
static Robot robot;
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //ProcessBuilder pb=new ProcessBuilder();
       
        //String[] com={“gnome-terminal”,”-e”,”./hello <in.txt> out.txt”};
       
       
//        “gnome-terminal –working-directory=myfolder”
        String[] command={
                “sudo rm -rf /home/hadoop”,
                “sudo mkdir /home/hadoop”,
                “sudo chown sist /home/hadoop”,
                “sudo mkdir /home/hadoop/hdfs”,
                “sudo chown sist /home/hadoop/hdfs”,
               
                “sudo mkdir /home/hadoop/hdfs/temp”,
                “sudo mkdir /home/hadoop/hdfs/data”,
                “sudo mkdir /home/hadoop/hdfs/name”,
                “sudo mkdir /home/hadoop/hdfs/mapred”,               
                “sudo chown sist /home/hadoop/hdfs/temp”,
                “sudo chown sist /home/hadoop/hdfs/data”,
                “sudo chown sist /home/hadoop/hdfs/name”,
                “sudo chown sist /home/hadoop/hdfs/mapred”
        };
        //Process proc=Runtime.getRuntime().exec(command);
        //String[] command={“wmctrl -l”};
       
        try{   

            Robot robot=new Robot();
           
            //
            ProcessBuilder pb=new ProcessBuilder();
           
            for(int i=0;i<command.length;i++){
               
                pb.command(“gnome-terminal”,”-e”,command[i]);
                Process pc=pb.start();
                System.out.println((i+1)+”/”+command.length+” “+command[i]);
               
                //끝나지 않았다면 딜레이
                if((i+1)<command.length){
                    robot.delay(3000);
                }
            }
           
        }
        catch(Exception ex){System.out.println(ex.getMessage());}

        System.out.println(“end”);
       
//        Runtime rt = Runtime.getRuntime();
//        String befehl = “gnome-terminal –command=\”ls\””;
//        try{
//        rt.exec(befehl);}
//        catch(Exception ex){System.out.println(ex.getMessage());}
//        System.out.println(befehl);
    }

}