Skip to content

Commit

Permalink
feat: threaded stdout stderr pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceh121 committed Aug 22, 2023
1 parent 51ef068 commit ce1e510
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions launcher/src/me/vinceh121/wanderer/launcher/LauncherFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ce1e510

Please sign in to comment.