Adding a java applet to your page

A java applet is a program that can run inside a web page.

If you intend to use java applets you need to remember
- a java enabled browser is required. IE6 does not support java directly, (it now requires a downloadable plugin)
- java requires someone who can program to write the applet

Embedding java Applets in Html

(Note:The code below uses the deprecated Applet tag. However it works in Netscape 7 and IE6.
The 'correct' W3C Object tag for embedding java applets is supported by Netscape but it is not properly supported by IE, so we will stick to the older method.)

The simple HTML code for including a Java applet goes into the body of an html document and is

<applet code='MyApplet.class' width='XX' height='YY'>
</applet>

where MyApplet.class is the file name of a compiled Java applet file, and WIDTH and HEIGHT are the pixel dimensions that the applet occupies on screen.

Quite often, you may want to send other information to the applet via parameters:

<applet code='MyApplet.class' width='XX' height='YY'>
<param name='param1' value='my1Value'>
<param name='param2' value='my2Value'>
</applet>

where each parameter has a name the applet is looking for and some value, which may be a string of text or a number:

<applet code='MyApplet.class' width='XX' height='YY'>
<param name='param1' value='The Meaning of Life is Cheese'>
<param name='param2' value='129'>
</applet>

Finally, you can include text that will be displayed only if the web browser does not support Java.
(Browsers tend to ignore anything inside tags they don't understand).
It's similar to using the ALT option for <img ...>tags or the <noframes> tag for frames.

<applet code='MyApplet.class' width='XX' height='YY'>
<param name='param1' value='my1Value'>
<param name='param2' value='my2Value'>
Sorry, but it looks as thought your web browser cannot display this cool Java applet.
</applet>

The text string inside the <APPLET>...</APPLET> tags is ignored by a Java-enabled browser since it is not an applet tag or a parameter tag) .

Examples - Checkout s:\cert4IT\internet1\html\java\starfield.html or

Embedding a java Applet