CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Applets

Applets
JAR
include JAR

The ARCHIVE attribute of the APPLET tag

Attribute Description
archive Specifies the archive file (such as a JAR file) to be downloaded.

How to include a JAR file that contains an applet in an HTML page

  • To improve the download time for your applets, you can place all the files needed by the applet in one JAR file.
  • Then, you can use the ARCHIVE attribute of the APPLET tag to specify the name of the JAR file.

An HTML page that uses the ARCHIVE attribute to specify a JAR file

<html>
  <head>
    <title>Future Value Calculator applet</title>
  </head>

  <body>
    <h1>Future Value Calculator applet</h1>
    <applet
      archive = "FutureValueApplet.jar"
      code = "FutureValueApplet.class"
      width = 240
      height = 175>
        <!-- If the browser can't display this applet, display this -->
        <p>This applet requires version 1.5 or later of Java.</p>
    </applet>
  </body>
</html>
Previous | Create and work | include JAR