У меня есть код:
public class Console extends Thread {
private static boolean run;
private TreeMap<Integer, String> commandMap = new TreeMap<>();
private ArrayList<String> query = new ArrayList<>();
private Process proc;
private BufferedReader in, err;
private PrintWriter out;
private int index;
private int currentIndex;
private Main main;
public Console(Main main) {
this.main = main;
setName("Console");
}
@Override
public void start() {
if(run) {
Dialog.show("Ошибка", "Сервер уже запущен!");
return;
}
main.cons_console.clear();
super.start();
}
public void stopConsole() {
run = false;
proc.destroy();
}
@Override
public void run() {
try {
run = true;
ProcessBuilder b = new ProcessBuilder(pathParser(Main.settings.lines)); //new ProcessBuilder("java", "-cp {path}");
b.directory(new File(Main.settings.corePath).getParentFile());
b.redirectErrorStream(true);
proc = b.start();
in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
out = new PrintWriter(proc.getOutputStream());
query q = new query();
process p = new process();
error e = new error();
q.setName("Console [Query]");
p.setName("Console [Process]");
e.setName("Console [Error]");
q.start();
p.start();
e.start();
} catch(Throwable t) {
Dialog.showStacktrace("Ошибка", "Ошибка при запуске консоли", t);
main.stopServ();
}
}
public String backCommand() {
String s = commandMap.get(currentIndex);
if(currentIndex > 0) currentIndex--;
return s;
}
public String forwardCommand() {
String s = commandMap.get(currentIndex);
if(currentIndex < index) currentIndex++;
return s;
}
public void onInsert(String value) {
query.add(value);
}
private String[] pathParser(String[] parse) {
String[] str = new String[parse.length + 1];
str[0] = "java";
for(int i = 1;i < parse.length + 1;i++) {
str[i] = parse[i - 1].replace("{path}", Main.settings.corePath).replace("java ", "");
System.out.println(str[i]);
}
return str;
}
public class query extends Thread {
public void run() {
while(run) {
try {
for (String s : query) {
out.write(s);
main.cons_console.appendText("> " + s);
commandMap.put(index, s);
if (currentIndex == index) currentIndex++;
index++;
}
query.clear();
} catch(Throwable t) {
Dialog.showStacktrace("Ошибка", "Ошибка при обработке очереди", t);
}
}
}
}
public class process extends Thread {
public void run() {
try {
String str;
while (run && ((str = in.readLine()) != null)) {
main.cons_console.appendText(" -> " + str + "\n");
}
} catch (Throwable t) {
Dialog.showStacktrace("Ошибка", "Ошибка при обработке входящих данных", t);
}
}
}
public class error extends Thread {
public void run() {
try {
String str;
while (run && ((str = err.readLine()) != null)) {
main.cons_console.appendText(" ->>> " + str + "\n");
}
} catch (Throwable t) {
Dialog.showStacktrace("Ошибка", "Ошибка при обработке ошибок", t);
}
}
}
Должен запускать программу. Также в неё можно что-то ввести. Но я получаю это: (Запуск сервера Minecraft(Да я школо))
-> Error: Could not create the Java Virtual Machine.
-> Error: A fatal exception has occurred. Program will exit.
-> Unrecognized option: -cp C:\Users\ender\Desktop\devServer\core.jar
Помогите, пожалуйста
P.S Не бейте тапками за плохой код)