문제 설명
itext와 같은 라이브러리로 Java 응용 프로그램을 배포하는 방법은 무엇입니까? (how to distribute a java‑application with libraries such as itext?)
저는 자바로 애플리케이션을 작성했습니다. iText
, jXL
및 JAI
를 사용합니다.
이러한 모든 라이브러리가 포함된 jar를 어떻게 빌드합니까? 아니면 사용자가 강제로 설치해야 합니까?
참조 솔루션
방법 1:
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
방법 2:
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
방법 3:
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.
방법 4:
You could use an utility like jarjar to merge your classes and the other libraries into a single deployable file.
방법 5:
Thanks for all solutions!
Fatjar is a great plugin for Eclipse that does all this too (:
(by Sven、Denis Tulskiy、jopasserat、perp、Elijah Cornell、Sven)