How to add Java applet to web page using applet, object, and embed tags?

These days were hard nightmare of debugging. The problem is that a Java Applet runs in Mozilla, but it doesn’t run in Internet Explorer.

I passes consecutively through these steps:

1) Test my current Java version on computer from here.

2) Check my Java settings from Control Panel and InternetOptions.

Finally I run my problematic webpage on Internet Explorer and look at the view source (with right click mouse –> open context menu –> select “View Page Source”). In the html source I saw that I have 2 tags (“object” and “embed”) which do the same work related to my applet. After that I found the root the problem: it was incorrect value of “classid”-attribute of “object”-tag. You can read a great article about how and when to use the applet, object, and embed tags to add Java applets to Web pages here.  You can read another good article here.

Here is the section which I needed it:

Using the object tag

You use the object tag to deploy applets that are to be used only with Internet Explorer.

Following is an example of the object tag:

<OBJECT
  classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  width="200" height="200">
  <PARAM name="code" value="Applet1.class">
</OBJECT>

The classid Attribute

The classid attribute identifies which version of Java Plug-in to use.

The example shown below is the most commonly used form of the classid attribute. This example instructs Internet Explorer to use the latest installed version of Java Plug-in.

classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 

Following is an alternative form of the classid attribute:

classid="clsid:CAFEEFAC-xxxx-yyyy-zzzz-ABCDEFFEDCBA" 

In this form, “xxxx”, “yyyy”, and “zzzz” are four-digit numbers that identify the specific version of Java Plug-in to be used.

For example, to use Java Plug-in version 1.5.0, you specify:

classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA" 

Using the object tag

You use the object tag to deploy applets that are to be used only with Internet Explorer.

For complete details on the object tag, read the W3 HTML specification.

Following is an example of the object tag:

<OBJECT
  classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  width="200" height="200">
  <PARAM name="code" value="Applet1.class">
</OBJECT>

The classid Attribute

The classid attribute identifies which version of Java Plug-in to use.

The example shown below is the most commonly used form of the classid attribute. This example instructs Internet Explorer to use the latest installed version of Java Plug-in.

classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

Following is an alternative form of the classid attribute:

classid="clsid:CAFEEFAC-xxxx-yyyy-zzzz-ABCDEFFEDCBA"

In this form, “xxxx”, “yyyy”, and “zzzz” are four-digit numbers that identify the specific version of Java Plug-in to be used.

For example, to use Java Plug-in version 1.5.0, you specify:

classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA"

Advertisements

About tsvetanv

Friends, Books, Music, Math, Programming.
This entry was posted in Java and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s