The Java Tutorial contains hundreds of complete working examples. Some of our examples are applets, others are standalone applications. This page contains three sections that discuss various aspects of our examples:
Each example belongs with a particular lesson and lives in an example directory within that lesson. A lesson might have one or more of the following example directories:
Example Directory Name Program Type JDK Release/Version Other libraries example
Applets and/or applications JDK 1.0.2 example-1dot1
Applets and/or applications JDK 1.1 example-1dot2
Applets and/or applications JDK 1.2 Beta 4 example-swing
Applets and/or applications JDK 1.1 Swing 1.1 Beta 3 example-swing-applet
Applets only JDK 1.1 Swing 1.0.3
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 inexample
and 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 JDK 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 typically lags the current release of the JDK, we need to provide multiple versions of each applet -- one that uses the latest version of the JDK, and one that users can run within their browsers.
- Some of the programs have been around since the original release of the JDK. Each version of the program represents a step in the natural migration of the program as the JDK evolves.
You will find four different versions of applets running on our pages:
- JDK 1.0.2 Applets
- These applets are included with an
<APPLET>
tag. We still run the 1.0.2 versions of the applets even if we have a 1.1 or higher version available because some older browsers don't support anything higher. This ensures that most of our readers can run the applet. These applets are followed by a note that looks like this (the links below don't work):
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. We run a 1.1 version of an applet only if no 1.0.2 version of the applet is available (usually because 1.0.2 doesn't support required functionality). 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.- JDK 1.2 Applets
- These applets are included with an
<APPLET>
tag. We run a 1.2 version of an applet only if no 1.0.2 or 1.1 version of the applet is available (usually because 1.0.2 and 1.1 don't support required functionality). These applets are followed by a note that looks like this:
Note: The above applet requires JDK 1.2. If you are using a browser that does not support 1.2, you won't be able to run the applet. Instead, you need to view this page in a 1.2 browser such as the JDK Applet Viewer (appletviewer
). For more information about running applets, refer to About Our Examples.- Swing Applets
- These applets require Java Plug-in 1.1.1 or a specially configured 1.1 browser. We include them using
<APPLET>
,<OBJECT>
, and<EMBED>
tags. Java Plug-in 1.1.1 supports Swing 1.0.3, so the running versions of these applets live inexample-swing-applet
. You can find the Swing 1.1 Beta 3 versions of these applets inexample-swing
, and you can run these with the Applet Viewer. For more information about running Swing applets, see Running a Swing Applet.Swing applets are followed by a note that looks like this (the links below don't work):
Note: Because the preceding applet runs using Java Plug-in 1.1.1, it is a Swing 1.0.3 version of the applet. To run the Swing 1.1 Beta 3 version of the applet, you can use the JDK Applet Viewer to viewnothing.html
, specifyingswing.jar
in the Applet Viewer's class path. For more information about running applets, refer to About Our Examples.