0
我试图运行调用运行时的shell脚本这个Java代码shell脚本。如何通过参数在java程序
当我在终端运行脚本我传递参数给脚本
代码:
./test.sh argument1
java代码:
public class scriptrun
{
public static void main(String[] args)
{
try
{
Process proc = Runtime.getRuntime().exec("./test.sh");
System.out.println("Print Test Line.");
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
如何通过论证在java代码脚本?
改为使用['ProcessBuilder'](http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html)。的 – NilsH
可能重复的[如何执行与参数命令?](http://stackoverflow.com/questions/7134486/how-to-execute-command-with-parameters) – Raedwald