Java Programs  «Prev  Next»
Lesson 3Understanding applications and applets
ObjectiveDescribe the differences between Java applications and applets.

Understanding Applications and Applets

Question: How does a Software Developer differentiate a Java Applet from a Java Application?
A Java applet is a small software program that runs within a web browser, typically to provide interactive features on a website. Applets are designed to be portable and can run on any platform that supports a Java Virtual Machine (JVM), which is a software layer that provides an environment for Java code to execute. In contrast, a Java application is a standalone program that is designed to be run on a specific operating system (such as Windows, macOS, or Linux) and is typically installed on the user's computer. Applications are not limited to running within a web browser and can access system resources, such as files and network connections.
In terms of development, applets are typically created using the Java Applet API, which provides a set of classes and interfaces for building applets. Java applications, on the other hand, are typically built using standard Java libraries and tools, such as the Java Development Kit (JDK) and the Java Standard Edition (Java SE) platform. To summarize, the key difference between a Java applet and a Java application is that an applet is designed to run within a web browser and is limited in its access to system resources, while an application is a standalone program that can access system resources and is designed to run on a specific operating system.


How JavaFX replaced the legacy Java Applets from the Dotcom Era

Java programs are broken down into two fundamental types:
  1. applets and
  2. applications.
As you may already know, applets are graphical programs that were used during the dotcom era. They are rarely used today and have been replaced by the JavaFX API.
Question: How has the JavaFx API replaced the Java Applets which were heavily used from 1996 to 2000?
The JavaFX API is a set of Java libraries and tools for building rich, graphical user interfaces (GUIs) and multimedia applications. While it can be used to build applets, JavaFX is not intended as a direct replacement for Java Applets. Java Applets were heavily used in the late 1990s and early 2000s as a way to provide interactive features on websites. However, their usage declined in the following years due to security concerns and the increasing popularity of other technologies, such as JavaScript and Flash. JavaFX was introduced in 2008 as a modern replacement for Java Applets, but with a focus on building rich desktop and mobile applications, rather than web-based applets. JavaFX provides a range of features for building modern, responsive applications with advanced graphics and multimedia capabilities.
While JavaFX can be used to build web-based applications, it is not typically used as a direct replacement for Java Applets on websites. Instead, JavaFX is more commonly used to build standalone desktop and mobile applications, as well as embedded systems and other types of software that require rich graphical interfaces and multimedia capabilities. In summary, while JavaFX can be used to build applets, it is not intended as a direct replacement for Java Applets on websites. Instead, JavaFX is a modern API for building rich desktop and mobile applications with advanced graphical and multimedia capabilities. Java applications are different from applets because they can be graphical or command-line. Applications do not require a Web browser and run entirely on their own. Command-line Java applications are ideal for creating simple utilities due to their minimal overhead. Graphical Java applications typically are larger in scope.
Graphical Java applications are like applets in many ways except for the fact that they are responsible for creating and managing their own frame window (a Web page serves as the frame window for an applet). Java applications (like Java applets) are created as classes but are executed using the Java interpreter[1] instead of a Web browser or the AppletViewer[2].
Applications and Applets

Security Distinction

Security plays the biggest role in distinguishing applets and applications. Applets are Web-based, which means that they could potentially cause lots of trouble on a computer with little warning. For this reason, they have Applets with Security.
Applications are manually installed by the user and are therefore considered secure by default, which means that they have little or no security limitations. The differing levels of security between applets and applications frequently result in limitations on what applets can functionally accomplish.
As an example, you could develop an application that searched the local hard drive for information, while an applet could not accomplish this task under normal circumstances due to its security limitations.

Application Applets - Quiz

Click the Quiz link below to check your knowledge of applications, applets, and the Java API.
Application Applets - Quiz

[1] Java interpreter: The Java interpreter is a program responsible for translating Java bytecode into native code that can execute on a given platform.
[2] AppletViewer: AppletViewer is a utility included with the Java Development Kit that allows you to test applets without using a Web browser.