Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Please take a bit of care editing your questions AND DON'T WRITE IN ALL CAPS!
Source Link
Mat
  • 208k
  • 41
  • 407
  • 423

PROCESS METHOD NOT EXECUTING DESIRED PROGRAM Process method not executing desired program

public class test2 {   public static void main(String[] args) {   try {     // print a message   System.out.println("Executing VLC.exe");       Process process = Runtime.getRuntime().exec("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe");     // print another message   System.out.println("VLC should now open.");     } catch (Exception ex) {   ex.printStackTrace();   }   }   } 

//

THE FOLLOWING IS THE ERROR:

Cannot run program "C:\Program": CreateProcess error=2, The system cannot findHere is the file specifiederror:

***>Cannot run program "C:\Program": 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 test2.main(test2.java:21) > 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)  ... 5 more*** 

BUT THIS PROGRAM RUNS NOTEPAD.EXE AND ASSOCIATED TEXT FILES RATHER EASILY.SO CAN IT ONLY RUN PROGRAMS IN WIN32? But this program runs notepad.exe and associated text files rather easily. So can it only run programs in Win32?

PROCESS METHOD NOT EXECUTING DESIRED PROGRAM

public class test2 {   public static void main(String[] args) {   try {   // print a message System.out.println("Executing VLC.exe");      Process process = Runtime.getRuntime().exec("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe");   // print another message System.out.println("VLC should now open.");   } catch (Exception ex) { ex.printStackTrace(); }   }   } 

//

THE FOLLOWING IS THE ERROR:

Cannot run program "C:\Program": 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 test2.main(test2.java:21) > 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) ... 5 more*** 

BUT THIS PROGRAM RUNS NOTEPAD.EXE AND ASSOCIATED TEXT FILES RATHER EASILY.SO CAN IT ONLY RUN PROGRAMS IN WIN32?

Process method not executing desired program

public class test2 { public static void main(String[] args) { try {   // print a message   System.out.println("Executing VLC.exe");   Process process = Runtime.getRuntime().exec("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe");   // print another message   System.out.println("VLC should now open.");   } catch (Exception ex) {   ex.printStackTrace();   } } } 

Here is the error:

Cannot run program "C:\Program": 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 test2.main(test2.java:21) 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)  ... 5 more*** 

But this program runs notepad.exe and associated text files rather easily. So can it only run programs in Win32?

Source Link
user2837260
  • 181
  • 3
  • 13

PROCESS METHOD NOT EXECUTING DESIRED PROGRAM

public class test2 { public static void main(String[] args) { try { // print a message System.out.println("Executing VLC.exe"); Process process = Runtime.getRuntime().exec("C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"); // print another message System.out.println("VLC should now open."); } catch (Exception ex) { ex.printStackTrace(); } } } 

//

THE FOLLOWING IS THE ERROR:

Cannot run program "C:\Program": 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 test2.main(test2.java:21) > 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) ... 5 more*** 

BUT THIS PROGRAM RUNS NOTEPAD.EXE AND ASSOCIATED TEXT FILES RATHER EASILY.SO CAN IT ONLY RUN PROGRAMS IN WIN32?