简体   繁体   English

如何初始化小程序并将其他jar添加到类路径? (《我的世界》自定义启动器)

[英]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. 抱歉,标题不好,但是本质上我需要做的是从另一个罐子中以applet形式启动一个罐子。 Also for those of you familiar with Minecraft, I'm making a custom Minecraft launcher. 同样,对于那些熟悉Minecraft的人,我正在制作自定义Minecraft启动器。 (The stub in the source is a subclass of AppleStub and has some custom parameters, etc.) (源代码中的存根是AppleStub的子类,并具有一些自定义参数,等等。)

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. 发生这种情况是因为我要启动的jar依赖于LWJGL,这是行不通的。 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). 这应该可以修复错误,但似乎不能解决(本地人只是natives文件夹的文件实例)。

The vanilla Minecraft Launcher does this almost exactly the same and works fine, whereas this does not. 普通的Minecraft Launcher几乎完全一样并且可以正常工作,而事实并非如此。 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. 看起来包含org.lwjgl库的JAR不属于启动程序的类路径的一部分。 You probably need to specify the location of the org.lwjgl JAR when you launch the launcher. 启动启动器时,可能需要指定org.lwjgl JAR的位置。 Something like: 就像是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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