eclipse 可运行的 jar 库处理选项之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8302894/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:44:07  来源:igfitidea点击:

What is the difference between runnable jar library handling options?

eclipsejarjava-web-start

提问by KJW

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.

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

  • Extract required libraries into JAR
  • Package required libraries into JAR
  • Copy required libraries into sub folder next to JAR.
  • 将所需的库提取到 JAR 中
  • 将所需的库打包到 JAR 中
  • 将所需的库复制到 JAR 旁边的子文件夹中。

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

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

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?

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

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?

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

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

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

回答by Michael

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

  2. Package required libraries into JAR- Puts the actual JAR filesof 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 .classfiles of your application.

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

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

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

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

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

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 andall the library code.

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