java jar中jar_java – jar中的jar

你将需要一个自定义类加载器为此,看看

One Jar。

One-JAR lets you package a Java application together with its dependency Jars into a single executable Jar file.

它有一个蚂蚁任务,可以简化它的建设。

Most developers reasonably assume that putting a dependency Jar file into their own Jar file, and adding a Class-Path attribute to the META-INF/MANIFEST will do the trick:

jarname.jar

| /META-INF

| | MANIFEST.MF

| | Main-Class: com.mydomain.mypackage.Main

| | Class-Path: commons-logging.jar

| /com/mydomain/mypackage

| | Main.class

| commons-logging.jar

Unfortunately this is does not work. The Java Launcher$AppClassLoader does not know how to load classes from a Jar inside a Jar with this kind of Class-Path. Trying to use jar:file:jarname.jar!/commons-logging.jar also leads down a dead-end. This approach will only work if you install (i.e. scatter) the supporting Jar files into the directory where the jarname.jar file is installed.


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部