如何使用 HTML 中的依赖项 jar 文件运行 Applet
我有一个包含小程序文件的 jar 文件,这些文件依赖于下面的附加 jar 文件。 它作为独立的 jar 文件运行良好。小程序使用:
xmlrpc-2.0.jar
commons-codec-1.3.jar
但是当我尝试在 HTML 中运行时,如下所示,它正在运行,但附加的附加 jar 文件是不与其绑定。我该如何解决这个问题?
<html>
<body>
<APPLET
CODE="MAIN.class"
WIDTH="100%" HEIGHT="100%"
ARCHIVE = "MAIN.jar,xmlrpc-2.0.jar,commons-codec-1.3.jar"
>
This example uses an applet.
</APPLET>
</body>
</html>
显现
Manifest-Version: 1.0
Main-Class: MAIN
Created-By: 1.3.0 (Sun Microsystems Inc.)
Class-Path: xmlrpc-2.0.jar commons-codec-1.3.jar
Name: MAIN.class
I have a jar file containing applet files which are dependent of below additional jar file.
Its running fine as standalone jar file. The applet uses:
xmlrpc-2.0.jar
commons-codec-1.3.jar
But when I tried to run in HTML as below, it's running, but attached additional jar files are not binding with it. How can I fix the problem?
<html>
<body>
<APPLET
CODE="MAIN.class"
WIDTH="100%" HEIGHT="100%"
ARCHIVE = "MAIN.jar,xmlrpc-2.0.jar,commons-codec-1.3.jar"
>
This example uses an applet.
</APPLET>
</body>
</html>
Manifest
Manifest-Version: 1.0
Main-Class: MAIN
Created-By: 1.3.0 (Sun Microsystems Inc.)
Class-Path: xmlrpc-2.0.jar commons-codec-1.3.jar
Name: MAIN.class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要 jar 文件与 MAIN.jar 位于同一文件夹中,它就应该可以工作。您能在 Java 控制台中看到任何与类路径相关的错误吗?
您还可以尝试使用清单文件,如下所述 此处。
It should work as long as the jar files are in the same folder than your MAIN.jar. Can you see any classpath-related error in the Java console?
You can also try to use a manifest file as described here.
FatJar for Eclipse 对我有用。当您打开多个项目时要小心,因为它倾向于从不相关的项目中获取其他内容并将其也滚动到您的 fatjar 中。
FatJar for Eclipse worked for me. Just be careful when you have multiple projects open, since it has a tendency to grab other stuff from non-related projects and roll that into your fatjar too.