Adds working test code for writing and reading console

This commit is contained in:
2018-01-26 15:59:49 +01:00
parent b9963c3a89
commit 83f012cf7f
2 changed files with 31 additions and 10 deletions

View File

@ -29,7 +29,7 @@ public class Server {
private ServerType type;
private String serverVersion;
private String maxRam;
private long pid;
private Process process;
public Server(String name) {
this.name = name;
@ -39,7 +39,7 @@ public class Server {
this.type = null;
this.serverVersion = null;
this.maxRam = ramList[0];
this.pid = -1;
this.process = null;
servers.add(this);
}
@ -64,6 +64,10 @@ public class Server {
return servers;
}
public Process getProcess() {
return this.process;
}
public void toggle() {
this.enabled = !this.enabled;
}
@ -120,11 +124,13 @@ public class Server {
System.out.println("File was not found.");
return;
}
Runtime rt = Runtime.getRuntime();
//Runtime rt = Runtime.getRuntime();
try {
System.out.println("Executing command.");
Process pr = rt.exec("\"java\" -Xmx" + this.maxRam + " -Xms512M -jar " + "\"" + this.path + "\\" + this.type + "\" nogui", null, new File(this.path));
this.pid = pr.pid();
ProcessBuilder builder = new ProcessBuilder("java", "-Xmx" + this.maxRam, "-Xms512M", "-Djline.terminal=jline.UnsupportedTerminal", "-Dcom.mojang.eula.agree=true", "-jar", "\"" + this.path + "\\" + this.getType() + "\"");
builder.directory(new File(this.path));
builder.redirectErrorStream(true);
Process pr = builder.start();
this.process = pr;
System.out.println("Success");
} catch (IOException e) {
System.out.println("Error");