Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Here are the steps for compiling and running your first Swing program with the Java 2 SDK, v 1.2 or 1.3:
Two versions of the Java 2 Platform are available, both for free. The first is the Java 2 SDK, Standard Edition, v 1.2, which is sometimes called "v 1.2" for short (or, incorrectly, "JDK 1.2"). The second is Java 2 SDK, Standard Edition, v 1.3, which is sometimes called simply "v 1.3".For information about the differences between 1.2 and 1.3, see the Java 2 SDK v 1.3 documentation.
You can use a simple program we provide, calledSwingApplication
. Please download and save this file:SwingApplication.java
. The spelling and capitalization of the file's name must be exactly "SwingApplication.java".
Your next step is to compile the program. Compiling a Swing program with one of the Java 2 SDKs is simple, since the Swing packages are part of the Standard Edition of the Java 2 Platform. Here is an example:If you can't compilejavac -deprecation SwingApplication.javaSwingApplication.java
, it's probably either because you're using a JDK 1.1 compiler instead of a v 1.2 or 1.3 compiler, or because you're using a beta release of v 1.2. Once you update a more recent release of the Java 2 Platform, you should be able to use the programs in this trail without change. See Swing Package Names for information about the package names that were used in the 1.2 beta releases.
After you compile the program successfully, you can run it. This section tells you how to run an application. For instructions on running an applet, see Running Swing Applets.Assuming that your program uses a standard look and feel -- such as the Java look and feel, Windows look and feel, or CDE/Motif look and feel -- you can use the v 1.2 or 1.3 interpreter to run the program without adding anything to your class path. For example:
If you use a nonstandard look and feel, you must make sure that its package is included in the class path. For example:java SwingApplicationSolaris: java -classpath .:/home/me/lnfdir/newlnf.jar SwingApplication Win32: java -classpath .;C:\java\lnfdir\newlnf.jar SwingApplication
Note: Don't include the core classes in the class path. The v 1.2 and 1.3 interpreters find them automatically.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.