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

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

问题描述

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




  • 将所需的库解压缩到JAR中


  • 将需要的库复制到JAR旁边的子文件夹中。



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



如果它是一个单一的jar,不是很容易,因为我不必写所有图书馆使用的所有不同路径?



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



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

解决方案


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


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


  3. 将需要的库复制到JAR旁边的子文件夹库JAR与可运行的JAR完全分离,所以可运行的JAR将只包含应用程序的 .class 文件。


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



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

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天全站免登陆