可运行的 jar 库处理选项之间有什么区别? [英] What is the difference between runnable jar library handling options?

查看:48
本文介绍了可运行的 jar 库处理选项之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我将使用 Java Web Start 来部署 Java 应用程序.导出到 Runnable Jar 时,eclipse Helios 中有三个选项.

  • 将所需的库提取到 JAR 中
  • 将所需的库打包到 JAR 中
  • 将所需的库复制到 JAR 旁边的子文件夹中.

有什么区别,它们将如何影响我的 .jnlp 文件?

如果它是单个 jar,是不是更容易,因为我不必为它使用的所有库编写所有不同的路径?

如果库和应用程序都发生了变化,单个 jar 会是更好的解决方案吗?或者我是否需要 <jar href=''> 每个单独的库?

另请注意,我需要使用本机库,如 .dll 和 .so 文件.

解决方案

  1. 将所需的库提取到 JAR 中 - 从您的应用使用的库中提取实际的 .class 文件并将这些 .class可运行 JAR 中的文件.因此,可运行的 JAR 不仅包含应用程序的 .class 文件,还包含应用程序使用的所有库的 .class 文件.

  2. 将所需的库打包到 JAR 中 - 将库的实际 JAR 文件放入可运行的 JAR 中.通常,JVM 无法加载 JAR 文件中的 JAR 文件.但是 Eclipse 向可运行的 JAR 添加了特殊的类来使这成为可能.

  3. 将所需的库复制到 JAR 旁边的子文件夹 - 使库 JAR 与可运行 JAR 完全分开,因此可运行 JAR 将仅包含 .class 您的应用程序文件.

选项#2 很方便,因为它将所有内容整齐地打包到一个 JAR 中,并将库 JAR 与应用程序的 .class 文件分开.

但是,将所有内容打包在单个 JAR 中(选项 #1 和 #2)的缺点是,如果您更新应用程序,则用户将不得不下载更多数据来更新应用程序.如果 JAR 保持分开,那么用户只需下载包含您的应用程序代码的 JAR,而不是下载包含您的应用程序代码和所有库代码的单个大型 JAR.>

So I will be using Java Web Start to deploy the java application. When exporting to a Runnable Jar, there are three options in eclipse Helios.

  • Extract required libraries into JAR
  • Package required libraries into JAR
  • Copy required libraries into sub folder next to JAR.

What are differences, and how will they affect my .jnlp file?

If it's a single jar, isn't it easier because I wouldn't have to write all the different paths to all the libraries it uses?

If there are changes in both the library and the application, a single jar would be a better solution? Or would I need <jar href=''> for each individual libraries?

Also note that I need to make use of native libraries like .dll and .so files.

解决方案

  1. Extract required libraries into JAR - Extracts the actual .class files from the libraries your app uses and puts those .class files inside the runnable JAR. So, the runnable JAR will not only contain the .class files of your application, but also the .class files of all the libraries your application uses.

  2. Package required libraries into JAR - Puts the actual JAR files of the libraries into your runnable JAR. Normally, a JAR file within a JAR file cannot be loaded by the JVM. But Eclipse adds special classes to the runnable JAR to make this possible.

  3. Copy required libraries into sub folder next to JAR - Keeps the library JARs completely separate from the runnable JAR, so the runnable JAR will only contain the .class files of your application.

Option #2 is convenient because it packages everything neatly into a single JAR, and keeps the library JARs separated from your application's .class files.

However, a downside to packaging everything inside of a single JAR (options #1 and #2) is that, if you update your application, then the user will have to download more data to update the application. If the JARs are kept separate, then the user would only have to download the JAR that contains your application code, instead of a single, massive JAR that contains your application code and all the library code.

这篇关于可运行的 jar 库处理选项之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆