用这个:
Runtime.getRuntime().exec(new String[] {"sh", "-l", "-c", "./foo"});要点:不要在双引号中使用。仅在外壳中编写命令行时使用!
例如,
echo "Hello, world!"(在shell中键入)被转换为:
Runtime.getRuntime().exec(new String[] {"echo", "Hello, world!"});(请暂时忘记外壳程序通常具有的内置功能
echo,而正在调用它
/bin/echo。:-))



