Could not find or load main class

  • Автор темы Автор темы xDark
  • Дата начала Дата начала
Статус
Закрыто для дальнейших ответов.

xDark

Активный участник
Пользователь
Баллы
96
Не знаю куда написать, поэтому пишу сюда. Вообщем проблема:
Есть код:

Java:
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("Type input file: ");
        String inputPath = scan.nextLine();
        if (inputPath == null) {
            System.err.println("Invalid path entered!");
            System.exit(-1);
            return;
        }
        File in = new File(inputPath);
        if (!in.isFile()) {
            System.err.println("Jar file does not exists.");
            System.exit(-1);
            return;
        }
        System.out.print("Type class path: ");
        String classPath = scan.nextLine();
        classPath = parse(classPath);
        String main = "net.minecraft.client.main.Main";
        System.out.print("Type native path: ");
        String natives = scan.nextLine();
        File nativeDir = new File(natives);
        if (!nativeDir.isDirectory()) {
            System.err.println("Native path is not a directory.");
            System.exit(-1);
            return;
        }
        System.out.print("Type name: ");
        String name = scan.nextLine();
        System.out.print("Type password: ");
        String password = scan.nextLine();
        try {
            ProcessBuilder builder = new ProcessBuilder();
            ArrayList<String> cmdList = new ArrayList<>();
            cmdList.add("java");
            cmdList.add("-Xmx2G");
            cmdList.add("-cp");
            cmdList.add(classPath.substring(0, classPath.length() - 1));
            cmdList.add("-Djava.library.path=" + nativeDir.getAbsolutePath());
            cmdList.add("-jar");
            cmdList.add(in.getAbsolutePath());
            cmdList.add(main);
            builder.command(cmdList);
            Process handle = builder.start();
            System.out.println("Process started.");
            System.out.println("Logs: ");
            BufferedReader out = new BufferedReader(new InputStreamReader(handle.getInputStream()));
            BufferedReader error = new BufferedReader(new InputStreamReader(handle.getErrorStream()));
            new Thread(() -> {
                while (true) {
                    String outS = scan.nextLine();
                    if (outS.equalsIgnoreCase("-exit")) {
                        System.exit(0);
                        break;
                    }
                }
            }).start();
            new Thread(() -> {
                while (true) {
                    try {
                        String outS = out.readLine();
                        if (outS != null)
                            System.out.println(outS);
                        outS = error.readLine();
                        if (outS != null)
                            System.out.println(outS);
                    } catch (IOException e) {
                        e.printStackTrace();
                        break;
                    }
                }
            }).start();
        } catch (Throwable t) {
            System.err.println("Failed to start process!");
            t.printStackTrace();
        }
    }
По началу все работает нормально, находит файлы, грузит библиотеки и т.д.
Но в конце вылетает ошибка:
0l6CLt4.png
P.S:
String main = "net.minecraft.client.main.Main";
Заранее спасибо.
 
Последнее редактирование:
Запускай так:
java (параметры) -cp minecraft.jar;(все библиотеки) (класс-запускатор)
 
Статус
Закрыто для дальнейших ответов.
Назад
Верх