Run command from java

0

I have the following code:

String java(){
    try {
        Process process;
        String file="If";
        process = Runtime.getRuntime().exec("java -verbose  If < codigo.txt ",null,new File(ruta));
        //process.waitFor();
        BufferedReader buf = new BufferedReader(new InputStreamReader(process.getInputStream()));

        String line;
        String output = "";
        while ((line = buf.readLine()) != null) {

            output += line + "\n";
            System.out.println(line);
        }
        System.out.println("Output: "+output);
        buf.close();
        return output;
    } catch (IOException e) {
        System.out.println("EXCEPTION: " + e.getMessage());
        return e.getMessage();
    }
}

I try to execute a command to compile from java another java code, the problem is to use < to enter input information to the class it locks up everything and nothing continues, then I have to kill the process

    
asked by Alan Mauricio 01.10.2018 в 04:21
source

0 answers