How do i run a UNIX terminal from Java and send commands to it?
问题 Regarding the topic, the code below Process proc = null; try { String[] cmdss= {"gnome-terminal"}; proc = Runtime.getRuntime().exec(cmdss, null, wd); } catch (IOException e) { e.printStackTrace(); } Runs the terminal form Ubuntu. How do I issue commands into the terminal after running the termnal? eg: running the terminal and run command such as "ls" etc. 回答1: You can give gnome-terminal some options on the command line what it shall execute. gnome-terminal -e /my/fortran/program The -x