I want to open the terminal (command prompt) on a Linux machine using Java code. I know how to open command prompt in windows.The following code i have used in windows
String command= "cmd c/start cmd.exe"
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
I need the same thing in Linux.
Thanks for your answers. I would like to run a sh script also.
Whether the following code works.
String command= "usr/bin/xterm myshell.sh";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
I would definitely provide an easy way to configure the path to the desired terminal in a place that can be easily edited. For example maybe in a configuration XML file.
Different distros will keep this in different places, so it's probably best to check the per distribution documentation for the platforms you're targeting (and to document how to change it).
"/usr/bin/xterm" should be on most machines, but I wouldn't necessarily bet the farm on it.
since you have to assume you know almost nothing about the system you are running this on, I'd say lowest common denominator would be:
String command= "/bin/sh";
String command= "sh";