I am trying to set up a minecraft server, for fun, and want to add a control panel to make managing it easier. Part of this control panel is to run the server FROM the panel to reduce miss-clicking the exit button and what-not. (the minecraft server is a non-runnable .jar file, implying you have to make a .bat to run it from the command line) I know how to run the server inside my program, as well as print the output, here:
ProcessBuilder pb = new ProcessBuilder("java", "-jar", "gscale.jar");
pb.redirectErrorStream(true);
pb.directory(new File("F:\\Documents and Settings\\Administrator\\Desktop"));
System.out.println("Directory: " + pb.directory().getAbsolutePath());
Process p = pb.start();
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
for (String line = br.readLine(); line != null; line = br.readLine()) {
System.out.println( line ); // Or just ignore it
}
p.waitFor();
but, with this, i'm not sure how to implement an input method. for example, if I click a button, it sends the input "stop" to the external jar to stop the server, as it does without this command panel. how would I implement that? the code above I plan to be running in it's own thread, but maybe i'm doing this all wrong?
Thanks in advance!