The Java Tutorial contains hundreds of complete working examples. Some of our examples are applets, others are standalone applications. For a complete list of the tutorial's applets, and what page to visit to run each one, refer to List of Applets.
This page contains four sections that discuss various aspects of our examples:
Each lesson in the tutorial contains one or more programming examples, each of which can be composed of one or more files. A lesson groups its examples in sub-directories according to the version of the Java 2 SDK required and whether Swing is required.A lesson might have one or more of the following example directories (from most up-to-date to least):
Example Directory Name Java 2 SDK Release/Version Other libraries example-1dot4Java 2 SDK 1.4 example-1dot3Java 2 SDK 1.3 example-1dot2Java 2 SDK 1.2 example-swingJDK 1.1 JFC/Swing 1.1 example-1dot1JDK 1.1 exampleJDK 1.0.2
Often, you can find multiple versions of the same program by looking in each of the example directories in a lesson. For example, you might find a JDK 1.0.2 version of a program inexampleand a JDK 1.1 version of the same program inexample-1dot1.We provide multiple versions of the same program for several reasons:
- Some developers can't upgrade to the latest version of the Java 2 SDK right away because of existing applications and users.
- It's often useful to compare two different versions of the same program to learn what kinds of changes are required to migrate from one release to the next.
- Because browser support for applets has historically lagged the current release of the Java Platform, we sometimes provide multiple versions of each applet -- one that uses the latest version of the Java 2 SDK, and one that users can run within less up-to-date browsers.
- Some of the programs have been around since the original release of the Java 2 SDK (formerly known as the JDK). Each version of the program represents a step in the natural migration of the program as the platform evolves.
Throughout the tutorial, you will encounter running applets. Our pages contain applets aimed at the following releases:[PENDING: These descriptions are ancient and need to be updated to the current status.]
- JDK 1.0.2 Applets
- These applets are included with an
<APPLET>tag and appear directly in content pages. Most browsers support 1.0.2, so most readers will have no trouble running these applets. These applets are followed by a note that looks like this:
Note: Because some old browsers don't support 1.1, the above applet is a 1.0 version (here is the 1.0 code; here's the 1.1 code). To run the 1.1 version of the applet, go toexample-1dot1/nothing.html. For more information about running applets, refer to About Our Examples.- JDK 1.1 Applets
- These applets are included with an
<APPLET>tag and appear directly in content pages. When we wrote these applets, many browsers did not support 1.1. If your browser does not support 1.1, then you will not be able to run these applets. These applets are followed by a note that looks like this:
Note: The above applet requires JDK 1.1. If you are using an older browser that does not support 1.1, you won't be able to run the applet. Instead, you need to view this page in a 1.1 browser, such as HotJava, the JDK Applet Viewer (appletviewer), or certain versions of Netscape Navigator and Internet Explorer. For more information about running applets, refer to About Our Examples.- 1.1/1.2 Swing Applets
- These applets require Java Plug-in 1.1.2, Java Plug-in 1.2, a 1.2 browser such as Applet Viewer, or a specially configured 1.1 browser. Because Swing support was not widely available when we wrote these applets and because we didn't want to force people to download Java Plug-in, these applets aren't included directly in content pages. Instead, the content page contains a snapshot of the running applet, which links to a separate page that contains the applet. For more information about running Swing applets, see Running Swing Applets
.
Swing applets are followed by a note that looks like this:
Note: Because the preceding applet uses the Swing 1.1 API, it requires Java Plug-in 1.1.2 or Java Plug-in 1.2. It won't work with Java Plug-in 1.1.1 or uncustomized 1.1 browsers. For more information about running applets in the tutorial, refer to About Our Examples. That page includes a section about Downloading Java Plug-in.- Java 2 SDK 1.2 Applets
- These applets require Java Plug-in 1.2 or a 1.2 browser such as Applet Viewer, and aren't included directly in content pages. Instead, the content page contains a snapshot of the running applet, which links to a separate page that contains the applet. These applets are followed by a note that looks like this:
Note: Because the preceding applet uses the Java 2 SDK 1.2 API, it requires Java Plug-in 1.2. It won't work with Java Plug-in 1.1.1, or Java Plug-in 1.1.2, or uncustomized 1.1 browsers. For more information about running applets in the tutorial, refer to About Our Examples. That page includes a section about Downloading Java Plug-in.- 1.4 Swing Applets
- These applets require more recent versions of Java Plug-in. They are followed by a note that looks like this:
Note: If you don't see the applet running above, you need to install Java Plug-in. For more information about running applets in the tutorial, refer to About Our Examples. That page includes a section about Downloading Java Plug-in.
If you already have the most recent version of the J2SE SDK, chances are the latest version of Java Plug-in is already installed in your browser. To test, go to a page that contains a 1.4 applet, such as How to Make Applets
. For help installing Java Plug-in, visit the Java Plug-in
product page.