Skip to Content
Java Cookbook
book

Java Cookbook

by Ian F. Darwin
June 2001
Intermediate to advanced
888 pages
21h 1m
English
O'Reilly Media, Inc.
Content preview from Java Cookbook

Running an Applet with a JDK

Problem

You want to use an applet on an intranet or the Internet, but it needs a modern JDK to run.

Solution

Use the Java Plug-in.

Discussion

Sun’s Java Plug-in allows your applet to run with a modern JDK even if the user has an ancient browser (Netscape 2, 3, or 4), or an anti-standard-Java browser (Microsoft Explorer might come to mind). For Netscape, the plug-in runs as a Netscape Plug-in. For Microsoft, the plugin runs as an ActiveX control. The Java Plug-in was previously a separate download, but is included in the Java Runtime Environment (JRE) in all modern JDK versions.

The HTML code needed to make a single applet runnable in either of those two modes rather boggles the mind. However, there is a convenient tool (which Sun provides for free) that converts a plain applet tag into a hairy mess of HTML that is “bilingual”: both of the major browsers will interpret it correctly and do the right thing. Note that since browser plug-ins are platform-dependent, the Plug-in is platform-dependent. Sun provides versions for Solaris and MS-Windows; other vendors provide it ported to various platforms. Learn more at Java’s Plug-in page, http://java.sun.com/products/plugin/.

To try it out, I started with a simple JApplet subclass, the HelloApplet program from Section 25.9. Since this is a JApplet, it requires Swing support, which is not available in older Netscape versions or newer MSIE versions. Here are some screenshots, and the “before and after” versions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java I/O

Java I/O

Elliotte Rusty Harold
Practical Cloud-Native Java Development with MicroProfile

Practical Cloud-Native Java Development with MicroProfile

Emily Jiang, Andrew McCright, John Alcorn, David Chan, Alasdair Nottingham

Publisher Resources

ISBN: 0596001703Catalog PageErrata