在罐子里使用JAR [英] Using JAR inside a jar
问题描述
我从我的java项目创建了一个JAR文件.使用Eclipse,我在自己的项目中添加了JAR作为引用库.但是,现在,当我尝试使用 java -jar myProgram.jar
运行程序的JAR时,出现了一个异常,指出我引用的jar不可用.
I created a JAR file from my java project.
Using Eclipse, I added a JAR as a referenced library in my own project.
However, now when I try to run my program's JAR using java -jar myProgram.jar
, I get an exception stating that my referenced jar is not available.
那么我如何创建一个包含对另一个JAR的引用的JAR并使其起作用?
So how can I create a JAR consisting a reference to a different JAR and make it work?
推荐答案
您需要使用Eclipse的可运行JAR导出器.由于Eclipse 3.5,在右键单击项目时具有以下选项,请选择导出>可运行的JAR文件
You need to use Eclipse's runnable JAR exporter. Since Eclipse 3.5 you've the following options when you rightclick project, choose Export > Runnable JAR file:
无论哪种方式,Eclipse都应确保您能够在导出的位置上以所需的方式运行JAR.
Either way, Eclipse should take care that you'll be able to run the JAR the way you want on the exported location.
这篇关于在罐子里使用JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!