Jump to content

Recommended Posts

Posted

I made a minimal launcher. It works just fine in Eclipse, but when I export launcher into runnable jar and execute it:

java -jar Microlauncher.jar -d %APPDATA%\.minecraft\bin -u alex55i -s 12345

I got an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: bdx
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getDeclaredMethod(Unknown Source)
        at cpw.mods.fml.relauncher.ReflectionHelper.findMethod(ReflectionHelper.java:170)
        at cpw.mods.fml.relauncher.FMLRelauncher.computeExistingClientHome(FMLRelauncher.java:195)
        at cpw.mods.fml.relauncher.FMLRelauncher.relaunchApplet(FMLRelauncher.java:241)
        at cpw.mods.fml.relauncher.FMLRelauncher.appletEntry(FMLRelauncher.java:212)
        at net.minecraft.client.MinecraftApplet.init(MinecraftApplet.java:25)
        at net.minecraft.Launcher.replace(Launcher.java:32)
        at net.minecraft.Launcher.setApplet(Launcher.java:21)
        at microlauncher.Main.main(Main.java:69)
Caused by: java.lang.ClassNotFoundException: bdx
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 24 more

 

Whats wrong with it?

 

Source code:

 

package microlauncher;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;

import javax.swing.JFrame;

import net.minecraft.Launcher;

public class Main {

public static void main(String[] args) throws Exception {

	String clientDir = ".";
	String username = "";
	String session = "";
	if (args.length > 0) {
		String arg = args[0];
		if ("-h".equals(arg) || "--help".equals(arg) || "/h".equals(arg)) {
			System.out.println("Usage: ");
			System.out.println("	java -jar Microlauncher.jar <>");
			System.exit(0);
		} else {
			int counter = 0;
			while (args.length > counter) {
				String op = args[counter++];
				if ("-d".equals(op)) {
					if (args.length > counter) {
						clientDir = args[counter++];
					}
				} else if ("-u".equals(op)) {
					if (args.length > counter) {
						username = args[counter++];
					}
				} else if ("-s".equals(op)) {
					if (args.length > counter) {
						session = args[counter++];
					}
				}
			}
		}
	}

	ArrayList<URL> classpathList = new ArrayList<URL>();
	classpathList.add(new File(clientDir, "lwjgl.jar").toURI().toURL());
	classpathList.add(new File(clientDir, "lwjgl_util.jar").toURI().toURL());
	classpathList.add(new File(clientDir, "jinput.jar").toURI().toURL());
	classpathList.add(new File(clientDir, "minecraft.jar").toURI().toURL());

	String nativespath = clientDir + "/natives";
	URL[] classpath = classpathList.toArray(new URL[0]);
	Applet applet = createApplet(nativespath, classpath);
	Launcher stub = new Launcher();
	stub.customParameters.put("stand-alone", "true");
	stub.customParameters.put("username", username);
	stub.customParameters.put("sessionid", session);

	JFrame frame = new JFrame("Minecraft");
	frame.setSize(800, 600);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setLayout(new BorderLayout());
	frame.add(stub);
	frame.validate();
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);

	stub.setApplet(applet);
}

public static Applet createApplet(String nativespath, URL[] classpath) throws Exception {
	System.setProperty("org.lwjgl.librarypath", nativespath);
	System.setProperty("net.java.games.input.librarypath", nativespath);

	URLClassLoader loader = new URLClassLoader(classpath);
	Class<?> appletClazz = loader.loadClass("net.minecraft.client.MinecraftApplet");
	return (Applet) appletClazz.newInstance();
}

}

 

package net.minecraft;

import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JPanel;

public class Launcher extends JPanel implements AppletStub {
private static final long serialVersionUID = 1L;
private boolean active;
public Map<String, String> customParameters = new HashMap<String, String>();

public void setApplet(Applet applet) {
	setLayout(new BorderLayout());
	replace(applet);
}

public void replace(Applet applet) {
	applet.setStub(this);
	applet.setSize(getWidth(), getHeight());
	setLayout(new BorderLayout());
	removeAll();
	add(applet);
	validate();

	applet.init();
	active = true;
	applet.start();
}

@Override
public boolean isActive() {
	return active;
}

@Override
public URL getDocumentBase() {
	return getClass().getProtectionDomain().getCodeSource().getLocation();
}

@Override
public URL getCodeBase() {
	return null;
}

@Override
public String getParameter(String name) {
	return customParameters.get(name);
}

@Override
public AppletContext getAppletContext() {
	return null;
}

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

@Override
public void paint(Graphics g) {
}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.