获取Java小程序找到嵌入在一个jar文件中的jar库 [英] Getting Java Applet to find jar libraries embedded in single jar file

查看:239
本文介绍了获取Java小程序找到嵌入在一个jar文件中的jar库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦我的Java小程序,它使用嵌入的jar库在网页中工作。具体来说,我得到包含在其本身包含在我的小程序的JAR文件的JAR文件里打包库类的NoClassDefFoundError。常规类后者(即那些不包含在嵌套jar文件)由该Applet启动位于没有任何问题。

I'm having some trouble getting my Java Applet, which uses embedded jar libraries to work in a web page. Specifically I get a NoClassDefFoundError for classes that are contained in libraries packaged inside jar files which are themselves contained in the single jar file of my Applet. The regular classes of the latter (i.e. those not contained in the nested jar files) are located by the Applet launcher without any problem.

下面是我的HTML code:

Here's my HTML code:

<applet code="Applet.class" archive="myApplet.jar" width="600" height="600" title="MyApplet">

说了,里面MyApplet.jar还有另外两个jar文件:library1.jar和library2.jar在根级别。我该如何让他们访问,以便发射能找到他们呢?我曾尝试加入library1.jar和library2.jar到存档属性,但没有奏效。

Say, inside the MyApplet.jar there are two further jar files: library1.jar and library2.jar at the root level. How do I make them accessible so that the launcher can find them? I have tried adding library1.jar and library2.jar to the archive attribute but that didn't work.

在此先感谢您的帮助。

推荐答案

您可以从您的依赖罐子其unjar的文件,包括他们在您的罐子。假设你有一个垃圾桶,SRC和库目录。

You could unjar the files from your dependency jars, and include them in your jar. Say you have a bin, src, and libs dir.

cd bin
find ../libs -type f -name \*.jar -exec jar xfv {} \;
rm -rf bin/META-INF
cd ..
jar cfv yourjar.jar -C bin/ .

这篇关于获取Java小程序找到嵌入在一个jar文件中的jar库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆