You can no longer create and run a Java applet in any current environment. Applets extended java.applet.Applet, ran inside a browser plugin, and that plugin technology was removed from browsers years ago. The Applet API was deprecated in Java 9, deprecated for removal in Java 17 and removed from the JDK in Java 26, so the modern replacement is a desktop Swing application or a web frontend.
This article shows what an applet looked like, why it stopped working and how to build the same "Hello" program with technology that runs today.
An applet was a Java class loaded from a web page by a browser plugin, running in a sandbox with restricted access to the user's machine. It was the main way to run Java in a page from the late 1990s. A typical applet looked like this:
It was compiled with javac and embedded in HTML with the <applet> tag, later replaced by <object> and the Deployment Toolkit script. Both are obsolete, and the <applet> element is not part of the current HTML standard.
This code is for reading older projects only. It does not compile on JDK 26 or later, because java.applet is gone, and even on older JDKs it produces a deprecation warning.
Several independent changes ended applets:
| Year | Change |
|---|---|
| 2015 | Chrome disabled the NPAPI plugin interface that Java used, and other browsers followed. Firefox ended support in 2017. |
| 2017 | Java 9 deprecated the Applet API and the browser plugin. |
| 2018 | Java 11 removed the Java Plugin and Java Web Start from the JDK. |
| 2021 | Java 17 marked the Applet API as deprecated for removal (JEP 398). |
| 2026 | Java 26 removed the Applet API (JEP 504). |
The reasons were security problems with browser plugins, the arrival of HTML5 features that made plugins unnecessary, and mobile browsers that never supported them. Dates are approximate for browser releases, so check the vendor's notes if you need exact versions.
If you maintain a legacy system, you can still compile an old applet with an older JDK such as 8, but there is no supported browser to run it in. Practical options are:
The appletviewer tool that once shipped with the JDK is also gone from current releases, so it is not a path forward.
For a desktop program, Swing is part of the JDK and needs no plugin. Save this as HelloSwing.java:
Compile and run it. With Java 11 or newer you can launch a single source file directly:
SwingUtilities.invokeLater creates the window on the event dispatch thread, which is required for Swing code. To distribute the program, package it with jpackage, which builds a native installer or app image with a bundled runtime.
If the goal was running Java logic in the browser, use one of these instead:
jpackage.For new web pages, use standard HTML, CSS and JavaScript. The browser draws on the <canvas> element where an applet used Graphics:
No. Current browsers do not include the plugin interface that applets required, so there is no supported way to run them in a mainstream browser.
No. Java remains widely used for servers, Android tooling, enterprise systems and desktop software. Only the browser plugin model was retired.
Java Web Start was removed in Java 11. Use jpackage for installable apps, or a regular web deployment for server-based software.
Replace Applet with JFrame or JPanel, move code from init to a constructor, replace paint with paintComponent, and add a main method.
Java applets belong to history: browsers dropped the plugin interface, and the Applet API was removed in Java 26. To build the same thing today, write a Swing application and package it with jpackage, or build the feature as a web application with standard HTML, CSS and JavaScript.