Вы выполняющиеся три команды подряд. Каждая команда должна быть отдельной Process
. Кроме того, команда и параметры должны быть разбиты на элементы массива:
Process send1 = Runtime.getRuntime().exec(new String[] {"javac", "/tmp/"+ fileName});
send1.waitFor(); // this returns an int with the exit status of the command - you really should check this!
Process send2 = Runtime.getRuntime().exec(new String[] {"sed", "-i", "s/Foo/Foo2/g", "/tmp/"+ fileName});
send2.waitFor();
Process send3 = Runtime.getRuntime().exec(new String[] {"java", "/tmp/"+ fileNameShort+".class"});
send3.waitFor();
С другой стороны, кормить всю вещь sh -c
(хотя на самом деле, на самом деле следует использовать предыдущий метод, то вы не имеете беспокоиться о побеге аргументы и т.д.)
Process send = Runtime.getRuntime().exec(new String[] {"sh", "-c", "javac /tmp/"+ fileName + "; sed -i 's/Foo/Foo2/g' /tmp/"+ fileName + "; java /tmp/"+ fileNameShort + ".class"});
Большое спасибо! Я использовал второе решение и работал. – birdcage