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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值