I'm trying to run a command from my java application. I get input from the user and run this line of code: Runtime.getRuntime().exec($userInput);
. I've tried lots of simple commands, including "echo," "start chrome," and "rem." It seems that the only command that works is "cmd.exe," and I have no idea what that even does.
Commands such as "echo" generate this error:
java.io.IOException: Cannot run program "echo": CreateProcess error=2, The system cannot find the file specified
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 me.Draconwolver.Main.runCmd(Main.java:119)
at me.Draconwolver.Main.main(Main.java:34)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Feel free to ask me for more details.