I started this week with Java so I’m a beginner, not sure if my question is as well, so I post it here. I would like my application to execute a command in cmd. The command looks likeSo my question is how do I do this?start "" /D "C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\release s\0.0.1.55\deploy" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 P3hNrXYZlaM3iJ9ximtzJWHbwLhvbimJ 953089676 EUN1"
I tried this, (just copy paste the command):
package MyProject; import java.io.IOException; import java.io.InputStream; public class Cmd { public static void main(String[] args) { try { final Process process = Runtime.getRuntime().exec("start \"\" /D \"C:\\Riot Games\\League of Legends\\RADS\\solutions\\lol_game_client_sln\\releases\\0.0.1.55\\deploy\" \"League of Legends.exe\" \"8394\" \"LoLLauncher.exe\" \"\" \"spectator 95.172.65.26:8088 P3hNrXYZlaM3iJ9ximtzJWHbwLhvbimJ 953089676 EUN1\""); final InputStream in = process.getInputStream(); int ch; while((ch = in.read()) != -1) { System.out.print((char)ch); } } catch (IOException e) { e.printStackTrace(); } } }
but than I get the error:
java.io.IOException: Cannot run program "start": CreateProcess error=2, Het systeem kan het opgegeven bestand niet vinden 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 MyProject.Cmd.main(Cmd.java:12) Caused by: java.io.IOException: CreateProcess error=2, Het systeem kan het opgegeven bestand niet vinden at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 5 more