Your browser has JavaScript turned off. This page is best viewed with Javascript enabled. Certain functions on this site will not work, and some style sheets will not load. Check your browser preferences to enable JavaScript.

Teach Yourself Java

What is an Applet anyway?

Java programs are divided into two categories - Applications and Applets. The main difference is that applets are run on a web page, while applications are run from the command line.

One of the most attractive aspects of the Java language is its ability to easily create programs for the internet; these programs are called Applets. Applets are similar to applications, but they don't run on their own. Applets are compiled Java programs which are run through either an Appletviewer or from a web browser. Applets run in their own frame (within the web page) and can do many things including displaying graphics, playing sounds, and accepting inputs (like mouse clicks or typing from the keyboard). Applets are commonly used to add interactivity to websites.

An Application is a stand-alone program that you generally run from the command prompt. You've used applications before (probably without realizing what it was). For example, when you type a paper using a word processor (like Microsoft Word), you are using an application (although not necessarily a Java application, it is an application none-the-less).

This tutorial is dedicated to Applets. The concepts of Java programming are the same for both applications and applets, but we made the executive decision to exclusively use Applets to illustrate Java concepts in this tutorial (for simplicity's sake). So if you want to learn how to write Java applications, you are welcome to stay, but be warned that all the examples in the tutorial are applets.