Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过JavaGUI运行Linux命令_Java_Linux_Terminal_Command_Runtime.exec - Fatal编程技术网

通过JavaGUI运行Linux命令

通过JavaGUI运行Linux命令,java,linux,terminal,command,runtime.exec,Java,Linux,Terminal,Command,Runtime.exec,我可以让我的终端显示,但我不能让我的代码运行:而且总是得到异常。知道怎么了吗 if (e.getActionCommand() == "Start") { String command= "/usr/bin/pg_ctl -D /var/lib/pgsql/data -l /var/lib/pgsql/log/pgsql.log start"; Runtime rt = Runtime.getRuntime(); try { rt.exec(command); } catch (IO

我可以让我的终端显示,但我不能让我的代码运行:而且总是得到异常。知道怎么了吗

if (e.getActionCommand() == "Start") {
String command= "/usr/bin/pg_ctl -D /var/lib/pgsql/data -l /var/lib/pgsql/log/pgsql.log     start"; 
Runtime rt = Runtime.getRuntime(); 
try {
rt.exec(command);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

运行时文档
中提到,如果要执行
命令和参数
,需要将其作为字符串数组
exec(String[]cmdarray)


请发布异常和堆栈跟踪。