[英]Creating Java applet using external JARS
I've created a Java Applet in Netbeans that uses several external libraries. 我在Netbeans中创建了一个使用多个外部库的Java Applet。 When I run the applet.java file within Netbeans it works fine and I'm trying to get the same result in a web page. 当我在Netbeans中运行applet.java文件时,它工作正常,我试图在网页中获得相同的结果。
When I run the automatically created applet.html-file in the build-folder it doesn't load the external library, even though I have specified them in APPLET archive-tag and moved them to the same folder. 当我在build-folder中运行自动创建的applet.html文件时,它不会加载外部库,即使我已在APPLET archive-tag中指定它们并将它们移动到同一文件夹中。
Here is my html-file: 这是我的html文件:
<HTML>
<HEAD>
<TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY>
<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>
<P>
<APPLET codebase="classes" code="applet/MyApplet.class" width=350 height=200 archive="jcommon-1.0.17.jar, jfreechart-1.0.14.jar, sqljdbc4.jar"></APPLET>
</P>
<HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT>
</BODY>
</HTML>
The libraries are 3rd-party java (jfreeChart and SQL-JDBC-driver) 这些库是第三方java(jfreeChart和SQL-JDBC驱动程序)
Creating Java applet using external JARS 使用外部JARS创建Java applet
Add a reference to them to the archive
attribute of the applet
element. 将它们的引用添加到applet
元素的archive
属性中。
<APPLET codebase="classes" code="applet/MyApplet.class" width=350 height=200 archive="jcommon-1.0.17.jar, jfreechart-1.0.14.jar, sqljdbc4.jar"></APPLET>
Reformatting that gives: 重新格式化给出:
<APPLET
codebase="classes"
code="applet/MyApplet.class"
width=350
height=200
archive="jcommon-1.0.17.jar, jfreechart-1.0.14.jar, sqljdbc4.jar">
</APPLET>
code="applet/MyApplet.class"
Should be the fully qualified name of the class. 应该是该类的完全限定名称。 If the class name is MyApplet
and the package is applet
, that translates to: 如果类名是MyApplet
并且包是applet
,则转换为:
code="applet.MyApplet"
archive="jcommon-1.0.17.jar, jfreechart-1.0.14.jar, sqljdbc4.jar">
Just checking, is applet.MyApplet in jcommon-1.0.17.jar
? 只是检查,是jcommon-1.0.17.jar
吗?
codebase="classes"
That sounds ominous. 这听起来很不祥。 Is this a full-blown web-app with JSP/servlets? 这是一个使用JSP / servlets的完整Web应用程序吗? If so, I suspect that path is wrong, in that it is pointing to a place on the server that a client (browser or) applet cannot reach. 如果是这样,我怀疑路径是错误的,因为它指向服务器上客户端(浏览器或)applet无法访问的位置。 Try doing a direct fetch (paste the expected address in the browser address bar, and hit 'enter') on each of the applet Jars, if the MyApplet.class
is not in a Jar, do a separate check on the loose class file. 尝试直接获取(在浏览器地址栏中粘贴预期的地址,并在每个applet Jars上点击'enter'),如果MyApplet.class
不在Jar中,请对松散的类文件进行单独检查。
package example.jni;
public class HelloWorld {
private static native void writeHelloWorldToStdout();
public static void main(String[] args) {
System.loadLibrary("HelloWorld");
writeHelloWorldToStdout();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.