kentoh - Fotolia

Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

What's the difference between applet and application in Java?

Java applets are no longer supported. How do they differ from applications? Let's explore their differences, as well as a brief history of the two terms among Java developers.

When Java Runtime Environment was released in 1996, there were two ways to distribute applications. One was as a stand-alone application that would run like any other and could be installed on a Windows- or Linux-based workstation. The second was as a Java applet that would run inside of a web browser.

Therein lays the key difference between applets and applications in Java. Java applets operate within a web browser, while Java applications do not.

Applet disambiguation

The term applet tends to cause some confusion when it describes a Java program that runs in a web browser. The word is commonly used in many different contexts throughout the technology world. For example, Microsoft's official documentation refers to individual programs, such as Device Manager and Power Options, as applets.

The word applet is often used interchangeably with the word widget or plugin. In general terms, any program that runs within another program -- or implements some type of subroutine within the confines of another application -- is often referred to as an applet. The greater program as a whole would be called the application.

With Java, you could think of the web browser as the application. The Java applet that runs within the web browser provides functionality that is dependent on the containing application. Hence, this is the main difference between an applet and an application in Java.

Applet support

How to run an applet
Applets that do not run in the browser will run with the AppletViewer.

Modern browsers no longer support Java applets, and if you attempt to view one in a webpage, it will normally trigger an error message that says, "Your browser is completely ignoring the <APPLET> tag." However, it is possible to run Java applets via the AppletViewer tool packaged with older versions of the JDK.

This animated GIF shows a browser that refuses to render an applet, followed by the webpage running via the AppletViewer application and resulting in the tic-tac-toe application execution.

Differences between applet and application in Java

From a coding standpoint, there are several important differences between an applet and an application in Java:

Category Applet Application
Deployment target Web browser Java Runtime Environment (JRE)
Parent class java.applet.Applet java.lang.Object
Default exceptions Constructor throws HeadlessException Throws no default exceptions
Packaging Class file or JAR Class file or JAR
Support Discontinued with Java 9 Supported with no talk of discontinuation

Java applet vs. application in code

The following image shows a simple Hello World application coded first as a Java applet and then as a Java application:

Applet vs. application code
Code for Java applet vs. application

Discontinued applet support

In 1996, the idea of a full-featured program running inside of a web browser was revolutionary. The ability to develop write-once, run-anywhere applications at the dawn of the internet age played an important part in Java's rise in popularity. In recent years, however, security flaws in the Java applet plugin and the introduction of powerful and easier-to-use JavaScript libraries caused client-side Java embedded in a web browser to fall out of favor.

In 2017, Oracle decided to remove the Java applet plugin from the JDK, and modern browsers like Chrome and Firefox will ignore any applets embedded within an HTML page.

Dig Deeper on Java platform tools and technology

Join the conversation


Send me notifications when other members comment.

Please create a username to comment.

What were the best uses of Java applet technology you experienced when they were commonly supported in web browsers?
What is the difference between applets and an application?
Application : It run on stand alone. Like you can run your java application in JRE.
Applet : You can run your applet program on web browser only.
Application : Contains only coding like methods and functions.
Applet : Contains tags,functins,methods and scripts.
Thank you it helped.