How to run minecraft

Discussion in 'Programming' started by Raizi, Mar 16, 2019.

  1. Hello.
    I create my launcher.
    I have a question: “How can I launch minecraft?” Is there any way?
    Thank.
     
    • Winner Winner x 1
    • Informative Informative x 1
    • Useful Useful x 1
  2. You want to make your own minecraft launcher?
     
  3. Yes, for of his project
     
  4. Afaik the launcher needs to authenticate with Mojang to launch Minecraft with the access token as a launch argument

    Edit: this page
     
  5. I need a code that runs the necessary files, is there such?
     
  6. Creeoer

    Supporter

    So basically you want someone to make the launcher for you, correct?
     
  7. [QUOTE = "Creeoer, post: 3342446, member: 3269"] То есть, в общем, вы хотите, чтобы кто-то сделал для вас пусковую установку, правильно? [/ QUOTE]

    No, maybe there is already a working code, I have a code, but there are errors with which I am already tired of fighting
     
  8. Creeoer

    Supporter

    Ok, so you tried something. I recommend sharing your code and asking for help with your specific errors instead of asking for a working version.
     
  9. Here is StartMU


    Code (Java):
    public class StartMU extends Applet implements AppletStub, MouseListener {
        private String bin;
        private URL[] url;
        private Applet mcApplet = null;
        public Map<String, String> ClientData = new HashMap<>();
        private boolean active = false;
        private int context = 0;
        public Applet applet;

        public StartMU(String bin, URL[] url) {
            this.bin = bin;
            this.url = url;

        }



        public void init() {

            URLClassLoader cl = new URLClassLoader(url);
            System.setProperty(bin + "libraries" + "org\\lwjgl\\lwjgl\\lwjgl.2.9.3", "natives"); //"natives"
            System.setProperty(bin + "libraries" + "net\\java\\jinput\\jinput.2.0.5", "natives");

            try {
                Class<?> main = cl.loadClass("net.minecraft.client.main.Main");
                Applet applet = (Applet) main.newInstance();
                applet.setStub(this);
                applet.setSize(getWidth(), getHeight());
                setLayout(new BorderLayout());
                add(applet, "Center");
                applet.init();
                active = true;
                validate();
            }catch (Exception e) {
                e.printStackTrace();
            }
        }

        public String getParameter(String name) {
            String custom = (String)ClientData.get(name);
            if (custom != null) return custom;
            try {
                return super.getParameter(name);
            } catch (Exception e) {
                ClientData.put(name, null);
            }return null;
        }

        public void start() {
            if (mcApplet != null) {
                mcApplet.start();
                return;
            }
        }
        public boolean isActive()
        {
            if (context == 0) {
                context = -1;
                try {
                    if (getAppletContext() != null)
                        context = 1;
                }
                catch (Exception e) {
                }
            }
            if (context == -1) return active;
            return super.isActive();
        }
        public void replace(Applet applet) {
            this.applet = applet;
            applet.setStub(this);
            applet.setSize(this.getWidth(), this.getHeight());
            this.setLayout(new BorderLayout());
            this.add(applet, "Center");
            applet.init();
            active = true;
            applet.start();
            this.validate();
        }

        public URL getDocumentBase() {
            try {
                return new URL("http://www.minecraft.net/game/");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            return null;
        }

        public void destroy() {
            if (mcApplet != null) {
                mcApplet .destroy();
                return;
            }
        }

        public void stop() {
            if (mcApplet  != null) {
                active = false;
                mcApplet .stop();
                return;
            }
        }







        @Override
        public void appletResize(int width, int height) {

        }

        @Override
        public void mouseClicked(MouseEvent e) {

        }

        @Override
        public void mousePressed(MouseEvent e) {

        }

        @Override
        public void mouseReleased(MouseEvent e) {

        }

        @Override
        public void mouseEntered(MouseEvent e) {

        }

        @Override
        public void mouseExited(MouseEvent e) {

        }
    }
     
    MainStart


    Code (Java):
    public class Start extends JFrame {


        private Map<String,String> ClientData = new HashMap<String, String>();

        public Start(String login, String session) {



            try {

                String bin = Update.getDirectory().toString() + File.separator + "bin" + File.separator;
                setForeground(Color.BLACK);
                setBackground(Color.BLACK);

                URL[] url = new URL[4];

                //url[0] = new File(bin, "libraries\\net\\sf\\jopt-simple\\jopt-simple\\5.0.3\\jopt-simple-5.0.3.jar").toURI().toURL();

                url[0] = new File(bin, "1.12.2.jar").toURI().toURL();
                url[1] = new File(bin,  "libraries\\org\\lwjgl\\lwjgl\\lwjgl.2.9.4-nightly-20150209\\lwjgl-2.9.4-nightly-20150209.jar").toURI().toURL();
                url[2] = new File(bin, "libraries\\org\\lwjgl\\lwjgl\\lwjgl_util.2.9.4-nightly-20150209\\lwjgl_util-2.9.4-nightly-20150209.jar").toURI().toURL();
                url[3] = new File(bin, "libraries\\net\\java\\jinput\\jinput.2.0.5\\jinput-2.0.5.jar").toURI().toURL();


                final StartMU startapplet = new StartMU(bin, url);
                startapplet.ClientData.put("username", login);
                startapplet.ClientData.put("session", session);
                startapplet.ClientData.put("stand-alone", "true");


                setTitle("Minecraft");
                //setBounds()
                //setExtendedState();
                addWindowListener(new WindowListener() {
                    @Override
                    public void windowOpened(WindowEvent e) {

                    }

                    @Override
                    public void windowClosing(WindowEvent e) {
                        startapplet.stop();
                        startapplet.destroy();
                        System.exit(0);

                    }

                    @Override
                    public void windowClosed(WindowEvent e) {

                    }

                    @Override
                    public void windowIconified(WindowEvent e) {

                    }

                    @Override
                    public void windowDeiconified(WindowEvent e) {

                    }

                    @Override
                    public void windowActivated(WindowEvent e) {

                    }

                    @Override
                    public void windowDeactivated(WindowEvent e) {

                    }
                });
                startapplet.setForeground(Color.BLACK);
                startapplet.setBackground(Color.BLACK);
                setLayout(new BorderLayout());
                add(startapplet, BorderLayout.CENTER);
                validate();
                setMaximumSize(new Dimension(800, 480));
                this.setVisible(true);
                startapplet.init();
                startapplet.start();

            } catch (MalformedURLException e) {
                e.printStackTrace();

            }


        }

        }
     
    Error


    Code (Text):
    Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: joptsimple/OptionSpec
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructor0(Class.java:3075)
        at java.lang.Class.newInstance(Class.java:412)
        at package.util.StartMU.init(StartMU.java:40)
        at package.util.Start.<init>(Start.java:94)
        at package.controller.Launcher.lambda$initialize$1(Launcher.java:100)
        at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
        at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
        at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
        at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
        at javafx.event.Event.fireEvent(Event.java:198)
        at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3470)
        at javafx.scene.Scene$ClickGenerator.access$8100(Scene.java:3398)
        at javafx.scene.Scene$MouseHandler.process(Scene.java:3766)
        at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
        at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
        at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432)
        at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
        at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
        at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
        at com.sun.glass.ui.View.notifyMouse(View.java:937)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.ClassNotFoundException: joptsimple.OptionSpec
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 37 more
     
  10. MiniDigger

    Supporter

    first you need to start by downloading all required files. you can see which files to download and where to place them here: https://wiki.vg/Game_files
    then you need to do authentication, altho you can skip that at first.
    then you need to launch the game, you can use the java process api for that. the arguments you need are saved in the version manifest of the version you are trying to launch.

    about your current code: don't use applets. they are ded. really. throw away your StartMU.
    generally your code looks like you want to launch minecraft classic? thats also kinda dead.
    what exactly do you want to do?
     
  11. When I click on the button, I want to download the client and unpack it (I know how to do it), then classic minecraft starts up, where there is the Network Play button, we go there,there is already a server, go in and play.

    Help me please.
     

Share This Page