import static java.lang.System.*;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.io.File;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException {
File homePath = new File(System.getProperty("user.home") + File.separator + ".jbang" + File.separator + "bin" + File.separator + "jbang.cmd");
String jbangPath = homePath.getAbsolutePath();
System.out.println(homePath);
List<String> command = new ArrayList<>();
command.add(jbangPath);
command.add("https://gist.github.com/maxandersen/28b00e9dcfc900111f868ab970eb7550");
ProcessBuilder pb = new ProcessBuilder(command);
try {
Process p = pb.start();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
String line;
System.out.println("Output:");
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
int exitCode = p.waitFor();
System.out.println("Exit Code: " + exitCode);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
}
}
}