Friday, 6 September 2013

Execute process from Java irrespective of underlying OS

Execute process from Java irrespective of underlying OS

Can you tell me a way to execute process from Java irrespective of
underlying operating system?
E.g. Process p = Runtime.getRuntime().exec("cmd /c mvn clean install");
Above line executes maven in windows environment but how can I run above
command in any operating system. If I don't add "cmd/c" in starting then I
am not able to run in windows environment and the error says cannot find
mvn.bat although maven home is set properly.

No comments:

Post a Comment