I’m just trying to open a command prompt window using java program (in eclipse). When i run pgm as below, it’s not showing any message
Runtime.getRuntime().exec("cmd");
But when i try to open internet explorer using below line
Runtime.getRuntime().exec("iexplore");
It’s throwing below error
Exception in thread "main" java.io.IOException: CreateProcess: iexplore error=2
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at dev.petrofac.ChangeFilePermission.main(ChangeFilePermission.java:17)
The fact is that you are starting cmd. Just because you can’t see it doesn’t mean it doesn’t start.
If you want to see the output from the application, you need to get the outputstream
(see Process for details). If you want to start cmd in a new window you can execute the string “cmd.exe /c start cmd.exe” instead, as in