如何使用 itext 等库分发 java 应用程序?

发布于 2024-10-04 19:31:52 字数 126 浏览 0 评论 0 原文

我用java写了一个应用程序。它使用 iTextjXLJAI

如何构建一个包含所有这些库的 jar?或者我是否也必须强迫用户安装这些?

I have written an application in java. It uses iText, jXL and JAI.

How do I build a jar which contains all these libraries? Or do I have to force the user to install these too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

吃不饱 2024-10-11 19:31:52

将 jar 解压到 jar 中,或者通过 Class-Path 属性位于你的元信息文件中,并将库与你的主 jar 一起分发。示例 META_INF/Manifest.mf:

Manifest-Version: 1.0
Class-Path: itext.jar jxl.jar jai.jar
Main-Class: com.xxx.yyy.Main

Either unpack the jars into your jar, or just add them to the jar classpath via the Class-Path attribute in your meta-inf, and distribute the libraries along with your main jar. Sample META_INF/Manifest.mf:

Manifest-Version: 1.0
Class-Path: itext.jar jxl.jar jai.jar
Main-Class: com.xxx.yyy.Main
想你的星星会说话 2024-10-11 19:31:52

一旦您处理外部库,您就应该看看 Maven。该工具是一个类似于 Ant 的构建器,但它能够自动处理库依赖关系。使用此构建器,您将能够将项目的依赖项嵌入到 jar 中,并允许用户在自己的计算机上构建它,而无需手动下载库依赖项。

这是该项目的网站:http://maven.apache.org/
您可以在其中找到快速操作方法: http://maven.apache.org/users/index.html html
最后是进一步发展的电子书: http://maven.apache.org/articles.html

As soon as you're dealing with external libraries, you should have a look at Maven. This tool is a builder such as Ant, but it is able to handle library dependencies automatically. With this builder, you'll be able to both embed your project's dependencies in your jar and also to allow users to build it on their own computer without downloading library dependencies manually.

Here is the project's website: http://maven.apache.org/
where you can find quick how-tos: http://maven.apache.org/users/index.html
and finally eBooks to go further: http://maven.apache.org/articles.html

爱你是孤单的心事 2024-10-11 19:31:52

在使用 Ant 构建项目时,您可以将所有 jar 打包到一个中。如果您使用 NetBeans,此页面介绍了如何修改 NetBeans 的构建脚本以为你做。

You could pack all jars into one while building your project with Ant. If you use NetBeans, This page describes how can modify NetBeans' build scripts to do it for you.

記柔刀 2024-10-11 19:31:52

您可以使用 jarjar 之类的实用程序将您的类和其他库合并到单个可部署文件中。

You could use an utility like jarjar to merge your classes and the other libraries into a single deployable file.

通知家属抬走 2024-10-11 19:31:52

感谢所有解决方案!

Fatjar 是一个很棒的 Eclipse 插件,它也可以完成这一切(:

Thanks for all solutions!

Fatjar is a great plugin for Eclipse that does all this too (:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文