How to embed a JApplet in HTML

Hi all,

When i use the <applet> tag in my browser for viewing a JApplet , I get an error saying class not found.Some of my friends say that the browsers do not support swing classes.IS there a way by which I can view my swing Applet in a browser(Netscape).

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

'cos ur using Swing u need to use Java plug-in to invoke the applet.
                for this u need to use <embed> & <object> tags.

                /**Swing applet on the browser**/

                1. The best solution is to use a plug-in.
                   The plug-in is bundled with jdk1.2.x
                else its available for download at,

                Trigger the plug-in
                to trigger the plug-in you need to include <OBJECT> & <EMBED> tags in your html file.
                Normally your HTML will contain,
                <APPLET  CODE = "myapplet.class" WIDTH = 300 HEIGHT = 300 > 
                The HTML file shud look like,
                <!-- CONVERTER VERSION 1.0 -->
                <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                WIDTH = 300 HEIGHT =
                300  codebase=",2,0,0">
                <PARAM NAME = CODE VALUE = "myapplet.class" > 
                <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
                <EMBED type="application/x-java-applet;version=1.2" java_CODE = "myapplet.class" WIDTH = 300
                HEIGHT =
                300   pluginspage=""><NOEMBED></COMMENT>

                <APPLET  CODE = "myapplet.class" WIDTH = 300 HEIGHT = 300 > 

                  This is done using the HTML convertor available for download at,

                2. Another option is to include the swingall.jar file into the browsers's classpath.
                3. Else bundle all the swing classes into your archive file & just state
                  <APPLET CODE=myApplet ARCHIVE=myJar.jar WIDTH=300 HEIGHT=300>
                where myJar contains all the swing classes used by myApplet
                This will make the download time of the jar file much slower 'cos the jar file size will be pretty high.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.