使用外部 JARS 创建 Java 小程序 [英] Creating Java applet using external JARS

查看:24
本文介绍了使用外部 JARS 创建 Java 小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Netbeans 中创建了一个使用多个外部库的 Java Applet.当我在 Netbeans 中运行 applet.java 文件时,它工作正常,我正试图在网页中获得相同的结果.

I've created a Java Applet in Netbeans that uses several external libraries. 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.

当我在构建文件夹中运行自动创建的 applet.html 文件时,它不会加载外部库,即使我已经在 APPLET 归档标签中指定了它们并将它们移动到同一文件夹中.

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.

这是我的 html 文件:

Here is my html-file:

<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>

库是 3rd-party java(jfreeChart 和 SQL-JDBC-driver)

The libraries are 3rd-party java (jfreeChart and SQL-JDBC-driver)

推荐答案

使用外部 JARS 创建 Java 小程序

Creating Java applet using external JARS

applet 元素的 archive 属性添加对它们的引用.

Add a reference to them to the archive attribute of the applet element.

<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>

重新格式化提供:

<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>

1.

    code="applet/MyApplet.class" 

应该是类的全限定名.如果类名是 MyApplet 并且包是 applet,则转换为:

Should be the fully qualified name of the class. If the class name is MyApplet and the package is applet, that translates to:

    code="applet.MyApplet" 

2.

    archive="jcommon-1.0.17.jar,  jfreechart-1.0.14.jar, sqljdbc4.jar">

检查一下,jcommon-1.0.17.jar中是applet.MyApplet吗?

Just checking, is applet.MyApplet in jcommon-1.0.17.jar?

    codebase="classes" 

这听起来不祥.这是一个带有 JSP/servlets 的成熟的 web 应用程序吗?如果是这样,我怀疑路径是错误的,因为它指向服务器上客户端(浏览器或)小程序无法到达的位置.尝试在每个小程序 Jar 上直接获取(在浏览器地址栏中粘贴预期地址,然后按回车"),如果 MyApplet.class 不在 Jar 中,请单独执行检查松散的类文件.

That sounds ominous. Is this a full-blown web-app with JSP/servlets? 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. 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.

这篇关于使用外部 JARS 创建 Java 小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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