by Clayton Walnum
Throughout this book, you've learned about Java and what Java can do for you on the Internet. You learned that small Java applications called applets enable you to include programs right in your Web pages and that you can also write standalone applications. However, if you were going to create your Java programs using only Sun Microsystem's Java Developer's Kit (JDK), you'd have to use a lot of command-line tools, including the Java compiler and interpreter. This usually means starting a DOS session under Windows and entering your command lines, along with appropriate parameters, in the DOS window.
If you're a person who likes the conveniences of running applications under a windowed environment such as Windows 95, you may be put off by having to go back to a command-line interface. That's why Sun Microsystems came up with Java Workshop. Java Workshop is like a sophisticated shell application for the JDK, enabling you to create applications from the familiar and easy-to-use Windows environment. By using Java Workshop, you can run most of the JDK's tools with a quick mouse click.
Java Workshop features many toolssome of which act as an interface between you and the JDKas well as others that are not included in the JDK, such as a text editor and a project manager. When used together, these tools comprise a powerful, graphical development environment that makes it easier and more enjoyable to create Java applets (and other Java projects). Java Workshop includes the following eight main tools:
The sections that follow introduce you to each of these tools.
If you've ever used other Windows development packages such as Visual C++ or Borland C++, you're already used to the idea of projects. A project is a collection of attributes that define how a program-in-progress is to be handled by the development environment. The attributes managed by a Java project include the names of all the source code files needed to compile the program, as well as how the program should be compiled and run. In Java Workshop, Project Manager organizes Java programs into projects.
Figure 50.1 shows what Project Manager looks like when you first start a new applet. All of the information you enter into the project dialog box is retained by Project Manager so that Java Workshop can handle the project's details without your intervention. Once you've set up a project, the task of compiling and running a program is as easy as clicking a button.
When you create a project, Project Manager stores the information you enter into the dialog box.
Of course, just because Project Manager handles the project's details for you doesn't mean you can't fine-tune things as needed. Java Workshop's Project menu enables you to create, delete, select, run, and copy projects. You can even edit any of the attributes that have been assigned to the current project. Figure 50.2, for example, shows some of the attributes that control how Java Workshop runs an applet. Most of these attributes have default values, but all may be edited by the programmer. As you can see in the figure, Project Manager enables you to edit six different categories of attributes, each category having its own tabbed page in the dialog box.
You can edit any of a projects attributes.
Once you start working on several different applets, you need a way to organize the projects that represent those applets, so that you can find what you need when you need it. You may even find yourself sharing Java Workshop with other users on a network, each user having his own set of projects on which he's working. Without some way to manage these projects, things can quickly get out of hand.
Enter Portfolio Manager, which organizes projects into a logical group called a portfolio. How you choose to set up a portfolio is up to you. You can, for example, have serious applets in one portfolio and games in another. Or, if several users are using Java Workshop concurrently, you can give each user his own portfolio. If set up properly on a network, you can even prevent unauthorized users from opening portfolios.
Portfolio Manager's main screen is a set of icons, each icon representing one project in the portfolio (see fig. 50.3). Each type of project (such as applet, stand-alone application, package, image, or remote applet) gets its own icon, so you can see at a glance not only what projects comprise the portfolio, but also what types of projects they are. Java Workshop's Portfolio menu contains commands that enable you to add, delete, select, or import portfolios.
Portfolio Manager organizes projects into logical groups.
At some point in the creation of your applet under Java workshop, you're going to want to compile your source code into the byte-code file that the Java interpreter can understand. This is the task of Build Manager (see fig. 50.4). Using Build Manager, you can compile whole projects or just single files. In the case of a project, Build Manager keeps track of files that are up-to-date and those that have to be recompiled; this avoids Java Workshop's having to compile source code files that haven't changed since the last build.
Build Manager compiles your Java programs.
As you can see in figure 50.4, Build Manager prints messages in its window as it works, keeping you informed of the compilation process. If your source code contains syntax errors, Build Manager displays the errors in the window, too, as shown in figure 50.5. Because Java workshop's tools are so tightly integrated, you can click an error message in Build Manager's window in order to load the source code file and automatically locate the offending line of code.
Build Manager also informs you of syntax errors in your source code.
Project Tester is one of the simplest of Java Workshop's tools to use, yet it makes testing your newly compiled applet a breeze. Just click Project Tester's button (the one that looks like a light switch) in Java Workshop's toolbar. Project Tester creates an HTML document for the applet (if needed) and runs the applet in Java Workshop's window. Figure 50.6, for example, shows Project Tester running one of the applets you wrote in Chapter 20, "Exceptions and Events in Depth."
Project Tester runs your applets.
Writing applets would be a tough job without some sort of text editor. Sure, you can use a marking pen to write your code directly on the computer screen, but saving it to disk is a real trick! Although you can edit your Java source code files with any text editor capable of saving plain-text (ASCII) files, Java Workshop includes its own text editor, called Source Editor. While it's true that Source Editor isn't the greatest editor that ever came down the pike, it is still quite usable and, more importantly, it is closely integrated with the other Java workshop tools, especially Build Manager and Debugger.
Figure 50.7 shows Source Editor in action. The editor includes a full set of editing commands, including text-block functions like cut and paste. Source Editor's fancy-looking toolbar has icons that enable you to open and save files, locate syntax errors, and control Java's debugger.
Source Editor is tightly integrated with other Java Workshop tools.
If you have experience with object-oriented programming, you know that sometimes it can be tough to keep track of where your classes come from. Although using techniques like inheritance enables you to write better classes faster, you don't want to spend a lot of time keeping track of your applet's family tree. Java Workshop's Source Browser tool handles this for you, as well as keeping track of which functions are where, so that you can jump to any function almost instantly. You can even search for occurrences of a given text string. No more scanning through long source code listings!
Figure 50.8 shows Source Browser's class page displaying the applet's inheritance tree. As shown in figure 50.9, Source Browser also creates a list of a class's methods. Just click a method in order to jump to it in Source Editor.
Source Browser can display a class's inheritance tree.
Source Browser can also display a list of a selected class's methods.
Finding occurrences of any text string in your source code is also easy with Source Browser. This particular task is handled by the String Search page, as shown in figure 50.10. After locating each occurrence of a text string, you can click one of the matches displayed in Source Browser's window to jump to the associated line in the source code.
Source Browser does string searches like a pro.
As all programmers know, creating even a simple program without introducing a bug or two is nearly impossible. Luckily, programming environments now usually include some sort of program debugger to help the programmer find and fix problems. Java Workshop is no exception, featuring the Debugger tool shown in figure 50.11. As you can see, Debugger's main display includes six pages of information about a currently running applet. By using this information, you can do everything from set breakpoints to trace the execution of threads and evaluate the current values of variables.
Debugger's main display offers six pages of debugging options.
When you run Debugger, Java Workshop also loads Source Editor with the current project's source code and runs a special debugging browser in which the applet is executed. During a debugging session, Source Editor's debugging toolbar is fully active (see fig. 50.12), enabling you to single-step through a program, set breakpoints, step over or into blocks of code, and more.
Source Editor is closely linked to Debugger.
One of the most exciting of Java Workshop's tools is Visual Java, which not only enables you to design your applet's interface before you start programming, but it also creates the starting source code for the applet when your design is done. Then, you need only customize the source code to make the interface perform as you like.
You start off your design using the layout frame window (see fig. 50.13) to create a grid of cells that will contain your applet's various components, such as buttons and text boxes. You then use Visual Java's toolbox to add components to the grid (see fig. 50.14) and create your applet's interface. Finally, you tell Visual Java to generate the source-code for the interface you've created (see fig. 50.15).
First, you create a grid of cells.
Then, you add components to the cells.
Finally, you tell Java Workshop to generate the source code.
Now that you know something about Java Workshop's tools, you'd probably like to see them firsthand. Follow these steps:
Before you can use Java Workshop, of course, you have to install it on your computer. Hop onto the World Wide Web, go to http://java.sun.com, and download your copy of Java Workshop. When you log on to the site, follow the developer links to Java workshop.
After you download Java workshop, you have a file called SETUPWS.EXE on your disk. Double-click this file to start the installation process.
After some setup, you see the screen shown in figure 50.16. Just follow the instructions in each of the Setup Wizard's dialog boxes to end up with a folder called JAVA-WORKSHOP on your hard disk. This folder contains your copy of Java workshop. Under Windows 95, the installation program also adds Java Workshop to your Start menu and adds a shortcut on your desktop.
The Java Workshop Setup screen appears.
| Previous Chapter | Next Chapter |
|Table of Contents | Book Home Page |
| Que Home Page | Digital Bookshelf | Disclaimer |
To order books from QUE, call us at 800-716-0044 or 317-361-5400.
For comments or technical support for our books and software, select Talk to Us.
© 1996, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon and Schuster Company