Is
Runtime.getRuntime().exec("cmd /c");
platform independent or I have to pass platform specific command in the parameter?
Thanks
What is the linux equivalent of the command cmd /c start /b java -jar
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Runtime.getRuntime().exec() is platform independant in the way, that it will start an external executable on every platform. The executable itself has to be there of course, so starting notepad.exe on Linux will very likely not work (except when you have Wine and Notepad installed, but this is another story).
On Windows, enter anything you would enter into cmd.exe (details follow). But to do the automatic path lookup on Windows, you need to do something like
or
which opens the pdf file with the associated viewer.
On linux, you can do anything you would do in a shell like Bash, but you cannot use bash builtins like the pipe operator. You can just start programs and pass arguments.
To start another Java instance on linux you could use:
Use the absolute path to the java executable if it is not on the PATH.