What Is an Applet?

A Java Applet is a small Java program designed to run inside another application - historically a web browser - rather than as its own independent process. Instead of starting from a public static void main(String[] args) method the way a normal Java program does, an applet is a class that extends java.applet.Applet (or, later, javax.swing.JApplet) and hands control of its own startup, drawing, and shutdown over to whatever container is hosting it. You don't call its methods yourself; the browser or a testing tool called appletviewer calls them for you, in a fixed order, at the right moments. That calling order is the applet lifecycle, covered in full in the next two lessons.

Set expectations early: the Applet API is a legacy, deprecated technology. It was deprecated starting in Java 9 (JEP 289) and marked "deprecated for removal" in Java 17 (JEP 398); it has since been removed from current JDK releases entirely. On top of that, no browser released in the last decade can run an applet at all - browsers dropped the plugin technology applets relied on years before the JDK itself deprecated the API. Nobody should reach for applets on a new project in 2026. You're learning this because it still shows up in college syllabi and certification material, because the AWT event model it teaches underpins Swing (and, indirectly, a lot of how Android's own event handling was designed), and because legacy codebases with applet code still exist. Keep that framing in mind for the rest of this track.

A Bit of History

Applets were introduced by Sun Microsystems in the mid-1990s, around the same time as the Java language itself and the early Netscape Navigator browser. At that point, HTML pages were almost entirely static, and JavaScript - itself brand new - could do very little beyond simple form validation and DOM tricks. Applets were Sun's answer to "how do we get real, general-purpose, compiled programs running inside a web page?" A browser with the right plugin installed could download a compiled .class file referenced by an HTML tag, load it into a sandboxed Java Virtual Machine, and run it right there on the page - complete with graphics, animation, and user interaction that plain HTML of the era simply couldn't offer.

For a while this was genuinely useful: interactive charts, simple games, chat widgets, and educational simulations were all common applet use cases in the late 1990s and early 2000s. Over time, though, JavaScript matured enormously, Flash (and later HTML5 canvas, video, and web APIs) took over rich media on the web, and the security problems inherent in running downloaded native-ish code inside a browser became harder to justify. Browser vendors eventually removed the plugin architecture (NPAPI) that applets depended on, and the technology quietly died out well before most developers noticed it was gone.

Applet vs. Standalone Application

The clearest way to understand an applet is to contrast it with the standalone Java application you already know - the kind you run with java ClassName from a main method. A standalone application owns its own process from start to finish: your code decides when it starts, what it does, and when it exits. An applet owns none of that. It is a passive class whose lifecycle methods are invoked by a host container, it draws into a rectangle the host gives it, and by default it runs inside a security "sandbox" that restricts what it's allowed to touch on the user's machine (no arbitrary file access, no arbitrary network connections outside its own originating server, and so on) unless it is specially signed and the user trusts it.

AspectStandalone ApplicationApplet
Entry point public static void main(String[] args) No main method - lifecycle methods (init, start, etc.)
How it's run java ClassName from the command line, or launched by an IDE/installer Embedded in an HTML page and loaded by a browser plugin, or tested with appletviewer
Process ownership Owns its own JVM process and its own execution flow Hosted inside the browser's JVM/plugin; the container drives it
Security model Full access to the local machine, subject only to the OS's own permissions Sandboxed by default - restricted file, network, and system access
Typical use case, then Desktop tools, servers, command-line utilities Interactive widgets, games, and simulations embedded directly in a web page
Typical use case, now Still exactly the same - alive and well None - superseded by JavaScript, HTML5 canvas/video, and installed apps

Why It's Still Worth Studying

Even with the browser story dead, the applet API is a compact, self-contained way to learn several ideas that matter well beyond applets themselves: a component-based lifecycle driven by a framework instead of your own code, drawing with the AWT Graphics object, and handling mouse and keyboard events through listener interfaces. These are the same foundational ideas Swing desktop applications use, and they echo in event-driven UI frameworks generally. Treat this track as a guided tour of that foundation using a genuinely simple, self-contained API, not as a technology you'll deploy.

Recap: An applet is a Java class (extending Applet or JApplet) with no main method, whose lifecycle is driven by a host container rather than by your own code, and which historically ran sandboxed inside a browser. The technology is deprecated, removed from modern JDKs, and unsupported by every current browser - it's taught here for its historical and educational value, not as something to ship.
Next steps: Before you can compile or run any applet code, you need the right JDK on your machine. Head to Environment Setup to get JDK 8 and appletviewer working alongside your regular Java setup.