简体   繁体   中英

How to init applets and add other jars to class path? (Minecraft Custom Launcher)

Sorry about the poor title, but essentially what I need to do is launch a jar in the form of an applet from another jar. Also for those of you familiar with Minecraft, I'm making a custom Minecraft launcher. (The stub in the source is a subclass of AppleStub and has some custom parameters, etc.)

applet.setStub(stub);

this.add(applet);

validate();
this.setVisible(true);

applet.init();
applet.setSize(getWidth(), getHeight());

applet.start();

Is my current code, which works, the only problem is I get this exception:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: 
    org/lwjgl/LWJGLException

Which happens because the jar that I'm launching depends on LWJGL, which doesn't work. I've already done this:

System.setProperty("org.lwjgl.librarypath", natives.getAbsolutePath());
System.setProperty("net.java.games.input.librarypath", natives.getAbsolutePath());

Which should fix the error, but doesn't seem to (natives is just the file instance of the natives folder).

The vanilla Minecraft Launcher does this almost exactly the same and works fine, whereas this does not. Does anyone know what I'm doing wrong?

It looks like the JAR that contains the org.lwjgl library is not part of your launcher's classpath. You probably need to specify the location of the org.lwjgl JAR when you launch the launcher. Something like:

java -classpath "path/to/lwjgl.jar" com.foo.MyLauncher

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM