Home > Back-end >  Java calls exe and mass participation
Java calls exe and mass participation

Time:09-21

Recently met a pass in the Java tuning exe and problem:
I direct incoming parameters in the CMD can successfully

Then write the following code in the Java how also failed (I tested in other exe, code no problem)
 public static void main (String [] args) throws the Exception {
List The command=new ArrayList (a);
Command. The add (" C: \ \ Users \ \ 18655 \ \ Desktop \ \ SQL \ \ sqlparser \ \ dist \ \ sqlparser exe ");
Command. The add (" insert into the node (id, name) values (13, luan);" );
Final Runtime Runtime=Runtime. GetRuntime ();
Process Process=null;



Try {
The process=new ProcessBuilder (command). The start ();
System. The out. Println (process. The isAlive ());
System. The out. Println (process);

Int exitVal=process. WaitFor ();//true
System. The out. Println (exitVal);//0
System. The out. Println (process. The isAlive ());//false

}
The catch (Exception e) {
System. The out. Println (um participant etMessage ());
}
}

CodePudding user response:

Solved, the problem of relative path/tears
  • Related