From ce1e5106b20be3bbfe799b4484856686a7f5a1e8 Mon Sep 17 00:00:00 2001 From: vinceh121 Date: Tue, 22 Aug 2023 16:07:19 +0200 Subject: [PATCH] feat: threaded stdout stderr pipe --- .../wanderer/launcher/LauncherFrame.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java b/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java index 00abb46..e379756 100644 --- a/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java +++ b/launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java @@ -2,6 +2,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.IOException; import java.nio.file.Path; import javax.swing.JButton; @@ -68,8 +69,22 @@ public void start() { Process proc = Runtime.getRuntime() .exec(new String[] { java.toAbsolutePath().toString(), "-jar", "desktop.jar" }); - proc.getInputStream().transferTo(System.out); - proc.getErrorStream().transferTo(System.err); + + new Thread(() -> { + try { + proc.getInputStream().transferTo(System.out); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + new Thread(() -> { + try { + proc.getErrorStream().transferTo(System.err); + } catch (IOException e) { + e.printStackTrace(); + } + }).start(); + proc.waitFor(); } catch (Throwable t) { LOG.error("Unexpected error", t);