The JavaTM Tutorial
Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Creating a GUI with JFC/Swing
Lesson: Getting Started with Swing

Platform-Specific Details: Setting the Browser's Class Path

You can make sure your browser's class path includes the Swing release in one of two ways:

Warning:  Permanently setting the CLASSPATH environment variable can lead to trouble, since it's easy to forget to update it when you use a different version of the JDK or Swing. Instead, try to specify the class path programmatically, such as with a -classpath command-line option. Or specify it at a shell prompt, rather than saving it in a file.
The following instructions give examples of each approach. For more information on setting the class path, see Managing Source and Class Files(in the Creating a GUI with JFC/Swing trail).

The directory paths used below assume that you have installed both the JDK and Swing releases under /home/me (for Solaris) or on drive C (for Windows). You should adjust the directory paths to reflect your installation.

Solaris
If you're using the JDK Applet Viewer, then instead of specifying the CLASSPATH environment variable, then you can use the -J option of the appletviewer command to specify options to the interpreter. For example:
appletviewer -J-classpath -J.:/home/me/swing-1.1.1/swing.jar:/home/me/jdk1.1.8/lib/classes.zip http://java.sun.com/docs/books/tutorial/uiswing/start/HelloSwingApplet.atag

If you choose to set the CLASSPATH environment variable, use a command like the following:

setenv CLASSPATH .:/home/me/swing-1.1.1/swing.jar
Then invoke your browser as usual.

Win32
If you're using the JDK Applet Viewer, then instead of specifying the CLASSPATH environment variable (as described in Setting Environment Variables), you can use the -J option of the appletviewer command. For example:
appletviewer -J"-classpath c:\swing-1.1.1\swing.jar;c:\jdk1.1.8\lib\classes.zip" http://java.sun.com/docs/books/tutorial/uiswing/start/HelloSwingApplet.atag

Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.