java - 如何在设置类路径时从另一个 JAR 启动外部 JAR?

标签 java applet classpath lwjgl slick2d

我想启动一个外部 JAR,我有其路径,存储在名为 jarPath 的字符串中。这个外部 JAR 在另一个名为 natives 的目录中具有多个依赖项。

如何在 Java Applet 中交换到此 JAR(如将 applet 代码的执行交换到外部 JAR 的代码)。外部JAR的主类是zombie.engine.Lighting2。

最佳答案

对于这次发布,我建议 Java Web Start .

使用 JWS 可以轻松部署 native ,就像将其他 Jars 添加到运行时类路径一样。小程序和应用程序(JFrameJWindow 等)自 JWS 1.2 中推出以来都可以使用 JWS 自由 float 启动,但来自 Sun 引入的 Plug-In 2 架构1.6.0_10 JRE,可以使用JWS部署嵌入式小程序。

使用此路由进行部署,您将:

  • zombie.engine.Lighting2 指定为main-class(在 JNLP 启动文件中)。
  • 使用 jar 元素添加依赖的 Jars。
  • 将 native 放入 Jar 文件的根目录中(每个操作系统一个 Jar 效果最好),并将它们添加到操作系统特定的 resources 元素中。

具有 native 的 Jars 以及同一 JNLP 中引用的任何其他 Jars 都需要进行数字签名,并且 JNLP 请求所有权限

<小时/>

I want to be able to load the JAR offline, ..

请参阅offline-allowed 元素。

offline-allowed element: The optional offline-allowed element indicates if the application can be launched offline.

If offline-allowed is specified, then the application can be launched offline by the Java Application Cache Viewer, and shortcuts can be created which launch the application offline.

..来自 information 的一部分JNLP 的要素。

..I want to have a custom load screen,

JWS 提供了一个简单的基于 GIF 或 JPEG 的启动画面,但看起来您正在谈论更多......

.. which incorporates custom functions for downloading the core game and logging in the user.

安装程序。对于安装人员,请参阅ExtensionInstallerService 。部分JNLP API 。安装程序可能经常需要的其他东西是 DownloadService/DownloadService2PersistenceService .

关于java - 如何在设置类路径时从另一个 JAR 启动外部 JAR?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8104352/

相关文章:

java - 使用 Java 运行 .reg 文件

java - Java 控制面板中没有安全级别滑动条

java - 哪个存储库有 eXist 以及如何使用 gradle 将其添加到类路径中?

java - 数组覆盖 ArrayList 中的数组

java - 获取 linkedhashmap 的第一项

java - 小程序。 java.lang.reflect.InvocationTargetException异常

java - Netbeans 导入的 JAR 在运行时未加载

java - 在注释处理器配置的生成源阶段需要来自 src/main/resources 的文件

java - 无法使用 java/keytool 签署挖掘签名

java - 如何将 Calendar 对象设置为当前日期,但包含 HH :mm:ss 的 SimpleDateFormat 中的时间