Java Applets in HTML

An applet is a Java program that can be included a web page by using HTML tags. The applet tag is the simpler but older method, and has been superseded by the object tag.

Applet - <applet> </applet>
Add a Java applet by specifying the attributes of the applet tag.
archive="url" - Address or filename of the Java archive file (.jar) containing the class files.
code="?" - Java class to run, eg. MyApplet.class
width="?" - The width of the applet, in pixels.
height="?" - The height of the applet, in pixels.
Object - <object> </object>
Use these attributes of the object tag to include an applet in html:
archive="url" - Address or filename of the Java archive file (.jar) containing the class files.
classid="?" - Java class to run, eg. java:MyApplet.class
codetype="application/java" - The type of object, use application/java.
width="?" - The width of the object, in pixels.
height="?" - The height of the object, in pixels.

Example:

Using both applet and object to show an applet

<html><body>
 <p>
  <applet code="Logo.class" archive="Logo.jar"
   width="740" height="400"></applet>
 </p>
 <p>
  <object codetype="application/java" classid="java:Logo.class"
   archive="Logo.jar" width="740" height="400"></object>
 </p>
</body></html>

See live demo of this example or open in a new window. (Note: close window or tab to return to the guide)

Example:

See the Logo Turtle Graphics Applet web page for more info on how to interact with the Logo applet.