diff --git a/Technology/ProcessDemo/src/ProcessDemo.java b/Technology/ProcessDemo/src/ProcessDemo.java index 9cd971c..7629274 100644 --- a/Technology/ProcessDemo/src/ProcessDemo.java +++ b/Technology/ProcessDemo/src/ProcessDemo.java @@ -6,8 +6,19 @@ public class ProcessDemo { public static void main(String[] args) { ProcessBuilder builder = new ProcessBuilder("C:\\Program Files\\HeidiSQL\\heidisql.exe"); try { + // Start the process Process process = builder.start(); - } catch (IOException e) { + + // Wait for the process to terminate + int exitCode = process.waitFor(); + + // Check if the process terminated successfully + if (exitCode == 0) { + System.out.println("Process executed successfully!"); + } else { + System.out.println("Process failed with error code: " + exitCode); + } + } catch (InterruptedException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }