A Beginner's Guide to Java WorkShop 3.0

Java WorkShopTM is a development environment for the Java programming language provided at no charge to developers (that's you!) from Sun Microsystems. WorkShop provides tools to make it easier to create, compile, debug and run Java programs and to organize these programs into larger projects. This page walks you through several activities that you need to do when developing with Java WorkShop. The page is organized into the following sections: This tutorial page is not meant to be a substitute for the full JWS documentation and tutorial which you can access through the Help menu item. This tutorial page is designed to be worked through in the order presented. The later sections specifically use the terminology introduced in the earlier sections (rather than re-explaining terms each time), so that you can tell whether you have mastered it.



Getting oriented to the Java WorkShop workspace

Java WorkShop has several screen areas shown in the image below:

NOTE: If you are having a lot of problems with the display in Java WorkShop, try setting the Look and Feel under Preferences to Motif. Also, Java WorkShop runs slowly on some machines and you may need to refresh the display manually if things don't quite look right (Reload Source File option on the File menu). Java WorkShop runs slowly, especially on older machines that don't have enough memory. Be patient.



Creating your first program in Java WorkShop

In order to create your program, you will:


Create a portfolio in Java WorkShop:

A portfolio is a way of grouping related programs together in the same way you might group email into folders. All of your programs will be organized into portfolios. A portfolio has a name and can contain one or more projects. These instructions assume that you will be organizing all of your programs into a single portfolio called programs.


Setting the default compiler in Java WorkSHop:

Java WorkShop uses a fast internal compiler by default. Unfortunately it doesn't do well with packages and may also have problems with the file permissions on our system. (The symptom of this problem is that you won't be able to compile a project because Java WorkShop can't create a create a file You should switch to the standard compiler. (Under Preferences select the Builder option to bring up the following window in which you can select the standard Java compiler as shown.)


Create a project in Java WorkShop:

Each program you write is called a project.


Insert code in the project:

Add a line to cause the program to display the message Hello World:


Compile and run the program in Java WorkShop:

Before you can run a program that you have written, you have to translate (compile) it in a form that the computer can execute. Java WorkShop uses the term Build for this translation process.



Making a simple applet:

An applet is a Java class that can be run from a browser. Applets can be tested by calling them from a web page, running them from an appletviewer or running them from Java WorkShop (which is what we will do here). In this exercise you will create an applet to output Hello World in an applet window.



Using a standard package

This exercise gives you instructions for using Java class libraries.



Adding a prewritten package

This exercise explains how to incorporate a prewritten package into your Java WorkShop environment. The steps are:

The exercise uses the simpleIO package provided as part of textbook Problem Solving with Java by Koffman and Wolz.



Adding your own class to a project



Adding your own package

Java comes with many libraries or packages that can extend the functionality of your program. You can also develop your own packages. This section works through an example of adding your own package in Java WorkShop. Be forewarned that the example is more complicated than the previous examples. We will create a package called PrettyPrint that contains a class called FancyText. FancyText stores a string and provides different ways of printing out the string (e.g. underlining or putting a box around it). After developing the PrettyPrint package, we will write a standalone test program called HelloSimple.

Create the PrettyPrint package:

Call the PrettyPrint package:


Create the PrettyPrint package:


Call the PrettyPrint package:



  • Java WorkShop FAQ (Frequently Asked Questions)


    Last Revision: October 6, 2000 at 4:33 pm
    This document was written by Kay A. Robbins. Please mail corrections and comments to krobbins@cs.utsa.edu