Comment and code additions

More comments are added.
More work on downloading server jars is done.
Server test added.
This commit is contained in:
2018-01-25 11:38:47 +01:00
parent b6685edc6f
commit 0c2c26e153
2 changed files with 14 additions and 6 deletions

View File

@ -1,7 +1,6 @@
import net.knarcraft.serverlauncher.server.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.*;
import java.util.ArrayList;
public class ServerTest {
@ -44,17 +43,24 @@ public class ServerTest {
if (server.isEnabled()) {
String path = server.getPath();
String type = server.getType();
try {
/* try {
server.downloadJar();
System.out.println("File downloaded.");
} catch (FileNotFoundException e) {
System.out.println("File was not found.");
return;
}
}*/
String ram = server.maxRam();
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + "\"" + path + "\\" + type + "\" nogui");
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + "\"" + path + "\\" + type + "\"", null, new File(server.getPath()));
String line;
BufferedReader in = new BufferedReader(
new InputStreamReader(pr.getInputStream()) );
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
long pid = pr.pid();
server.updatePid(pid);
System.out.println("Success");