且构网

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

从命令行将JAR依赖项与可执行JAR(ÜberJAR)捆绑在一起

更新时间:2022-12-12 22:40:41

遗憾的是,您的方法完全错误。
没有正常的方法将jar 放在另一个jar的里面。所以你的hello.jar在main.jar中无关!关键是普通类加载器不会在jar中查找jar文件,因此你会得到类找不到错误。
但是:如果你想要desparetly这样做,那么google为OneJar并转到 http:/ /one-jar.sourceforge.net/

Your approach is completely wrong unfortunately. There is no "normal" way to place a jar inside of another jar. So your hello.jar has nothing to do inside of main.jar! The point is the "normal" classloader wont look for jar files inside of jars, hence you get the class not found error. However: if you want desparetly to do that, then google for "OneJar" and go to http://one-jar.sourceforge.net/