Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems viewing applets with different browsers,

Applet Problems

Problems viewing applets with different browsers,

by  ackka  Posted    (Edited  )
This is a faq that i decided to write because of the large number of posts about this problem.

Bascially an Applet is a really small program that operates inside of a single class and is very limited in what it can do. The Applet is interepreted differentely by whatever Java Runtime Engine you are using. Each browser uses a different version of Java Runtime Engine. Microsoft Internet Explorer 4.x,5.x, decided to write their own version of the Java Runtime Environment. Netscape uses Sun's version and usually is pretty reliable. So bascially you need to force the browser to use the Sun Microsystems version of the Java Runtime Environment to make sure that your applets look the same in "most" browsers.

Sun knows this and has provided the java plugin to work with whatever version of the JDK you used. If you are using Swing or anything after JDK1.1 you will have to force the user to download the JDK1.3 Plug-in. The way to do this is in the html file. In Internet Explorer plugins have to be modified by a way of registry access to work correctely. Netscapes just uses the tags. So instead of having to write the html file for each applet you create. Sun provided a application that converts your html automatically.

To download the Java Plugin Version 1.3 here is the link

http://java.sun.com/products/plugin/index.html

To download the Java Html converter here is the link
http://java.sun.com/products/plugin/1.3/features.html

Notice: These links will change, as what happened with the last FAQ I wrote so go to Java.sun.com and do a search for Java Plugin

------------------------------------------------------------------------------------
This is the code to link to an Applet using the AppletViewer or in Netscape
Code:
<html>
<body>

<applet code ="Whatever.class" archive="Whatever.jar" width=200 height=200>
</applet>

</body>
</html>

Unfortunately Micro$oft decided that it would not play nice. So if you use the previous code to call your applet certain things will not work. The reason for this is that you are not using the Sun plugin, you are using Micro$oft's version. To force the Sun plugin to activate you need to use the following code

Code:
<html>
<body>

<!--&amp;quot;CONVERTED_APPLET&amp;quot;-->
<!-- CONVERTER VERSION 1.3 -->
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 200 HEIGHT = 200  codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
<PARAM NAME = CODE VALUE = "Whatever.class" >
<PARAM NAME = ARCHIVE VALUE = "Whatever.jar" >

<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<COMMENT>
<EMBED type="application/x-java-applet;version=1.3"  CODE = "Whatever.class" ARCHIVE = "Whatever.jar" WIDTH = 200 HEIGHT = 200  scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT>

</NOEMBED></EMBED>
</OBJECT>

<!--
<APPLET CODE = &amp;quot;Whatever.class&amp;quot; ARCHIVE = &amp;quot;Whatever.jar&amp;quot; WIDTH = 200 HEIGHT = 200>


</APPLET>
-->
<!--&amp;quot;END_CONVERTED_APPLET&amp;quot;-->


</body>
</html>
------------------------------------------------------------------------------------
This code is designed to work for Netscape and IE, and will both auto download the Java Plugin and also link to Applet to the plugin....This code will not work in the AppletViewer in the JDK

If you don't feel like typing this in all the time Sun very nicely created an application that converts this html automatically, also allows you to enter parameters etc... it can be found at
http://java.sun.com/products/plugin/1.3/features.html


good luck

tom

thomas.moses@gmail.com
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top