Хостинг серверов Minecraft playvds.com
  1. Вы находитесь в русском сообществе Bukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на русский язык плагины наших собратьев из других стран.
    Dismiss Notice

Could not find or load main class

Discussion in 'Разработка плагинов для новичков' started by xDark, May 2, 2017.

Thread Status:
Not open for further replies.
  1. Автор темы
    xDark

    xDark Активный участник Пользователь

    Trophy Points:
    96
    Skype:
    ailyashevich
    Имя в Minecraft:
    xDark
    Не знаю куда написать, поэтому пишу сюда. Вообщем проблема:
    Есть код:

    Code:
        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();
            }
        }
    
    По началу все работает нормально, находит файлы, грузит библиотеки и т.д.
    Но в конце вылетает ошибка:
    [​IMG]
    P.S:
    String main = "net.minecraft.client.main.Main";
    Заранее спасибо.
     
    Last edited: May 2, 2017
  2. Хостинг MineCraft
    <
  3. Larin

    Larin Старожил Пользователь

    Trophy Points:
    103
    Запускай так:
    java (параметры) -cp minecraft.jar;(все библиотеки) (класс-запускатор)
     
  4. Автор темы
    xDark

    xDark Активный участник Пользователь

    Trophy Points:
    96
    Skype:
    ailyashevich
    Имя в Minecraft:
    xDark
    Спасибо
     
Thread Status:
Not open for further replies.

Share This Page