Creating a Java applet using external JARS

I created a Java applet in Netbeans that uses several external libraries. When I run the applet.java file in Netbeans, it works fine, and I'm trying to get the same result on a web page.

When I run the automatically created applet.html file in the build folder, it does not load the external library, even if I specified them in the APPLET archive tag and moved them to the same folder.

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>

Libraries are third-party java (jfreeChart and SQL-JDBC drivers)

+5
source share
2 answers

Creating a Java applet using external JARS

Add a link to them in the archiveelement attribute 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>

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>

1.

    code="applet/MyApplet.class" 

. MyApplet, applet, :

    code="applet.MyApplet" 

2.

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

, applet.MyApplet jcommon-1.0.17.jar?

3.

    codebase="classes" 

. - JSP/? , , , , ( ) . ( 'enter') Jars, MyApplet.class Jar, .

+9
package example.jni;

public class HelloWorld {
    private static native void writeHelloWorldToStdout();

    public static void main(String[] args) {
        System.loadLibrary("HelloWorld");
        writeHelloWorldToStdout();
    }
}
0

All Articles