且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Ant 将库打包到我的 jar 中

更新时间:2023-09-30 13:08:52

您可以在 jar 的清单中添加Class-path"行.缺点是您必须硬编码清单中文件系统(而不是 jar)位置的路径.如果你把它们都放在同一个目录或一致的相对目录中,应该是可以管理的.

You can add a "Class-path" line to your jar's manifest. The drawback is that you have to hard code the paths to a file system (not jar) location in the manifest. If you put them all in the same directory or a consistent relative directory, it should be manageable.

参见:http://docs.oracle.com/javase/教程/部署/jar/downman.html

或者,您可以尝试使用 One-JAR:http://one-jar.sourceforge.net/

Alternately you can try something line One-JAR: http://one-jar.sourceforge.net/