Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Tricks of the Java Programming Gurus

Chapter 24 -- Integrated Development Environments

Chapter 24

Integrated Development Environments


As you begin to do more development in Java, you may desire a more robust environment than notepad and the DOS prompt. Your environment should support your coding effort, making implementing and debugging easier and more pleasant. The editor should enable you to easily locate the portion of the code you want to work on. It also can ease the implementation of a particular coding style or project standards. Because you are recompiling often, having the compiler just a click away will decrease the time and frustration in your development process. This chapter investigates a few of the many integrated development environments that are being created for the Java language. These environments are applicable to both applets and applications, so an example of each is given in this chapter.

The Examples Used in This Chapter

Before getting into a specific development environment, it makes sense to have a good idea of the program you are going to develop. This section introduces the examples used in this chapter and reviews how they would be created without an integrated development environment.

Example One: myapplet

The applet developed in this chapter displays a single .gif file and its caption. The code for the applet is shown in Listing 24.1 and 24.2. To create and run the applet under Windows 95 you would do the following:

  1. Type Listing 24.1 into a file named using notepad or another text editor.
  2. Type Listing 24.2 into a file named using notepad or another text editor.
  3. Compile in a DOS window using the command: javac
  4. Compile in a DOS window using the command: javac
  5. Locate and fix any compilation errors.
  6. Type Listing 24.3 into a file named myapplet.html.
  7. Use the appletviewer, Netscape, or another browser to open myapplet.html.

The integrated development environments presented in this chapter make each of these steps faster and easier than working from the command line.

Listing 24.1.
import java.awt.*;

public class myapplet extends java.applet.Applet {

    public void init() {
        Image theImage;

        setLayout(new BorderLayout());
        add("North",new Label("SAMS Logo"));
        theImage = getImage(getCodeBase(),"samsnet.gif");
        add("Center",new myCanvas(theImage));
        resize(150, 150);

Listing 24.2.
import java.awt.*;

public class myCanvas extends java.awt.Canvas {
    Image localImage;

    public myCanvas(Image theImage) {
        localImage = theImage;
    public void paint(Graphics g) {

Listing 24.3. myapplet.html.
<TITLE> Applet Tester </TITLE>

<APPLET CODE="myapplet.class" WIDTH=200 HEIGHT=100></APPLET>



Example Two: myapplication

Because building an application is slightly different from building an applet, it makes sense to give an example of each. Running an application is, of course, very different from running an applet because applications are run using the java interpreter rather than a browser. The environments presented here provide a means of running applications as well as applets.

The application developed in this chapter is very similar to the applet created in the listings above. It displays a single GIF with a caption. It provides a frame with an appropriate title for the application to run in and a button to close the frame and end the program. It borrows the myCanvas class from the applet. The remaining code for the application is shown in Listing 24.5. The steps to create an application follow:

  1. Type Listing 24.4 into a file named using notepad or another text editor.
  2. Copy myCanvas.class into the same directory if it is not there.
  3. Compile in a DOS window using the command javac
  4. Locate and fix any compilation errors.
  5. From the command line, run the application using the java command.

The integrated development environments help shorten the time to perform each of these steps and make reusing code between applications more simple.

Listing 24.4.
import java.awt.*;

public class myapplication extends Frame {
    public myapplication()
        Image theImage;

        setLayout(new BorderLayout());
        add("North",new Label("SAMS Logo"));
        theImage = getToolkit().getImage("Samsnet.gif");
        add("Center",new mycanvas(theImage));
        add("South",new Button("OK"));
    public boolean handleEvent(Event evt){
        if ( == Event.WINDOW_DESTROY || instanceof Button ) {
            return true;
        return false;
    public static void main( String args[] )
        myapplication localmyapplication = new myapplication();
        localmyapplication.setTitle("Show Logo");;

The remainder of this chapter shows how these two examples can be developed in several different integrated environments. This chapter does not provide exhaustive coverage of each environment-that would require several books this size! This chapter should be enough to get you in and moving around in each environment.

Symantec's Cafe Lite

Symantec has the advantage of having the first integrated development environment for Java. The full version is known as Cafe. A scaled-down, evaluation version known as Cafe Lite is being included on CD with several books on Java programming. More information on Symantec's Café and Café Lite is available at


There are a number of books and utilities that include Symantec's Cafe Lite on CD-ROM. Installation from the CD-ROM is easy; just run the Setup.exe utility that comes with the software. A standard installation program prompts for name, company, and installation directory. It then proceeds to install Cafe Lite in the specified directory. The complete installation includes a subdirectory containing Java sources and the JDK.

The only unexpected feature is that the installer set Cafe as the default application for files with the extension .java. You don't have to worry anymore about clicking on Java files and having them appear in notepad. Unfortunately, after installation, when a Java file is activated from Windows Explorer, Cafe starts but does not automatically load the file selected in Explorer.

Creating the Applet

Integrated development environments group the code for each applet into a project. The code resides in different files based on the Java classes, but a project is created to store the names of all files related to an applet. Each applet or application constructed in Cafe will need to be part of such a project. The Cafe environment makes it easy to create a new project and include Java files in the project.

Starting a Project in Cafe Lite

After Cafe has been installed, click on the Cafe icon or select Scw32.exe in the Cafe/bin directory to start Cafe. From the startup screen you can create a new project with a new applet. Take the following steps:

  1. Select Project|New from the main menu. A project wizard dialog box appears, as shown in Figure 24.1, to step you through creating the project.
  2. Choose the directory for the project.
  3. Give the project a name.
  4. Place an X in the box labeled "Use App Express to create new application."
  5. Click finish.

Figure 24.1 :The project wizard for Cafe Lite.

The project has been created and you are now ready to create the Java files for the applet. In fact, the applet wizard is waiting for information about the file you are creating.

Entering and Editing Code in Cafe Lite

With the applet wizard running, your screen should appear as shown in Figure 24.2. Be sure the application type is set to Java Applet, and then click Next.

Figure 24.2 : First Page of the Application Wizard for Cafe Lite.

The next screen in the wizard deals with the directory for the new file. The directory entry box in the wizard should default to the directory for the project you just created. Verify the default and click Next.

The following page gives you the opportunity to enter your company information and the year the program is created. Change this information to reflect the project you are working on.

The remainder of the screens affect features which are not editable in the Cafe Lite version. In the full Cafe version it is possible to select a name for the applet, the file where it is stored, and the .html file which invokes it. The Lite version only creates an applet named simple. For the moment, select Finish to complete creating the applet. Once the applet is created you can change the name of the class and the file.

You can now Select Project|Build to build the new project and then Project|Execute Program to run the project. The applet viewer runs, displaying the default applet. This default applet displays the text "simple applet" to the user.

You now need to modify the default applet to reflect the applet in Listing 24.1. You also need to create another file to hold the code in Listing 24.2. From the main menu, select File|Open and open Select New! from the menu on the edit window. A new file is created with the same code as

Use the File|Save As option to save one file as and the other as In each case, be sure that the box labeled "Add to project" is marked. Your project now contains three Java files. Select the Project tab to see the files contained in your project. The file is not needed for your project, and can be removed by clicking on it with the right mouse button and selecting Delete from the menu which appears.

As an alternative, adding and deleting files from a project may be done from the window which is displayed from the Project|Edit menu selection.

Return to the editing tab and modify the code in each file to reflect Listings 24.1 and 24.2. Notice that the editor changes the color to reflect the syntax of the listing, resulting in code that is easier to read. When all of the code has been entered, you are ready to compile the project.

Compiling in Cafe Lite

To compile the project on the main menu, select Project|Rebuild All. If you select Project|Build, Cafe recommends that you rebuild all the files and then prompts you to do so.

If an error occurs, it appears in the output window. Double-clicking the error selects the line of code that is suspected of causing the error. Figure 24.3 illustrates an error condition. Double-clicking on an error in the output window moves the focus to the line in the file where the error occurs. You can then edit that line and recompile. Once the applet has been correctly compiled it is ready to run.

Figure 24.3 : Compilation Errors in Cafe Lite.

Running in Cafe Lite

You still need an HTML file to run the applet. Cafe uses Simple.html as the file to pass to the appletviewer when the appletviewer is started. Use File|Open to open the file Simple.html, and edit it so it looks like Listing 24.3. These changes will cause Simple.html to reference the class myapplet.

Select Project|Execute Program to run the applet. The screen should appear as shown in Figure 24.4.

Figure 24.4 : Running the applet in Cafe Lite.

Debugging in Cafe Lite

Suppose the program runs but does not behave as expected. Cafe provides access to the JDB to enable runtime debugging of the applet. To run the JDB in a DOS box, select Debug|Start/Restart Debugging from the main menu. Once you have the applet running correctly, you can begin work on the application.

Creating an Application in Cafe Lite

You need to create a new project to hold your application. Creating a project for an application is almost exactly the same as creating a project for an applet.

Setting up the Application in Cafe Lite

When you reach the application wizard in Cafe Lite, select the Java Console option instead of the Java Applet. This creates your new file as a stand-alone application rather than an applet. The wizard creates a new version of It also verifies that you want to create this project in the same directory as an existing project. This does not mean that you are overwriting the existing project.

Unfortunately, since Cafe Lite does not support changing the runtime argument, you need to create the application with the name Simple. Open the file and modify it to reflect the code in Listing 24.4. Replace myapplication with Simple throughout the code.

Compiling and Running the Application in Cafe Lite

Because the application makes use of the myCanvas class, you need to include the code for this class as part of the new project. From the main menu, select Project | Edit, and display the Dialog Box for editing the project. Add the file to the project. That's all there is to it. Including existing code can be a simple process!

Be sure to check the output tab after each compile, to verify that your code compiled successfully.

Use Project|Rebuild All to compile the new code. Check the output tab to verify that the code compiled successfully, then use Project|Execute Program to execute your new program.

Not being able to change the argument to the Execute Program option can be a bit frustrating, but a little creative directory structuring can prevent this from being a real problem. You did not really want to put all of your projects in the same directory anyway; it would be a management nightmare. However, this feature and the class hierarchy browser are available in the full version of Cafe, which can be purchased from Symantec. There is also a class editor in the full version of Cafe.

For more information concerning Cafe and Cafe Lite, visit Symantec's Web Site at

ED for Windows, The Java IDE

ED for Windows is an advanced editor that supplies development assistance for 30 different languages, including Java. The editor integrates with compilers for each language, in this case javac, to provide assistance in removing compilation errors. It also enables you to trigger execution of your code from within the editor.

Installation and Setup of ED for Windows

A 30-day evaluation copy of ED for Windows can be downloaded from This document also contains price and ordering information for ED. The download is a single ZIP file which must be expanded. It includes an installation program, install.exe. Running the installation program enables you to specify the directory for ED installation and then neatly installs all of the needed files. The installation procedure creates a Windows group with an icon to start ED. Double-click the icon to start up the ED environment and get the screen shown in Figure 24.5.

Figure 24.5 : The startup screen of ED for Windows.

ED can be set up to provide a class hierarchy browser for the Java classes. Unfortunately, this process is a little more involved than the initial installation of the editor. Read the ED Help screen on Hierarchical Class and Method Browser for more complete instructions on how to set up the class hierarchy browser.

The class browser is very handy when you're working in ED and worth taking the time to configure. However, the setup is currently a three-step process that requires significant user interaction.

  1. On the main menu, select Tools|Make Function Tags to bring up the dialog box. Select Java as the language, the source files as *.java, and then make tags for one of the directories containing Java source files. Repeat this step for each of the other directories containing Java source files.
  2. Select Options|Paths & API Help|Tag Paths, and pull up a dialog box where you can specify which files will be used to build the hierarchy tree. You should add each of the files you just created to the specification list and remove any default files which are not applicable to your directory setup. Place an X in the box before each file that you want included in the hierarchy browser.
  3. Finally, on the main menu, select GoTo|Source Browser, and a new window containing the hierarchy of objects and methods is displayed. A view of ED with the hierarchical source browser open is shown in Figure 24.6. This process seems needlessly complex-hopefully it will be shortened in the future.

Figure 24.6 : ED for Windows screen with Class Hierarchy Browser.

Creating an Applet in ED for Windows

Just as the Cafe environment made it easy to create the applet, ED makes it easy to create a HelloWorld applet. The code for the applet is included as a skeleton in the environment. To make use of this, open a new file using the File|New menu option, and name the file with the File|Save As menu option. Select Macro|Skeletons from the main menu. The dialog box containing a list of available skeletons is displayed. Scroll down in the dialog box until you can select the Hello World (applet) under the heading Programs. Once you have selected this option, click the Insert button. The code for the Hello World applet appears in your editing window. You can skip to the Compile and Run section to run the Hello World applet or you can create the example applet from Listing 24.1.

Other skeletons, more useful for developing new applications, are also included with ED. You can create your own skeletons for inserting frequently used code. You can modify existing skeletons to conform to coding standards and conventions at your site. The use of code skeletons is a handy time-saver that decreases syntax errors and makes code creation less painful.

Starting a New File in ED for Windows

Before creating an applet in ED, you will probably want to change the default directory. You should create a separate directory for each project that you write under ED. To change the default directory, use the main menu option File|Change Directory. Set the new directory to the directory where you want to store the applet.

Once you have the default directory established, start a new applet by selecting File|New from the main menu. Use File|Save As to save the applet with the name Be sure to change the file extension. ED defaults the file extension to .JAVA, which does not compile correctly. Case sensitivity can have its drawbacks.

Entering and Editing Code in ED for Windows

You can use both the skeletons and the class hierarchy browser to assist you as you enter the code for myapplet. If you have not already done so, choose Macro|Skeletons to bring up the Skeletons dialog box. This box may also be opened by selecting the tenth button from the left on the main toolbar. The ED screen with the Skeletons dialog box is shown in Figure 24.7.

Figure 24.7 : ED for Windows screen with Skeleton Dialog.

To begin editing code, double-click Comments Header in the dialog box and a comment is inserted at the top of the active window. Fill in the appropriate file information, then add the import lines.

In the dialog box, select class under the Constructs heading and press insert to get the following code fragment:

public class extends

The cursor sits between the words "class" and "extends". Fill in myapplet before extends and Applet { after extends.

Now open the Java class hierarchy browser by selecting Goto | Source browser. Look at the methods available for the Applet class. Double-click init and a new window is displayed showing the init() method as defined in the Applet class. You can cut and paste this method into your new code rather than typing.

When the Java class hierarchy browser first displays, all of the classes are open. To make it easier to look through the listing, click the box before Object to close all the classes. Click it again and the classes are displayed, but not their subclasses. Click the box in front of each class to see its subclasses.

Within the init() method, declare the local variable. On the class hierarchy browser find setLayout. Click the insert button and the method name is inserted into your code. Inserting names from the class hierarchy browser can be handy for preventing typos, especially case sensitivity problems. Using the class hierarchy browser to find the appropriate method names, continue adding the remaining code for this file.

Open another file and save it as Repeat the procedure above to create the myCanvas class with appropriate comments and methods. Figure 24.8 shows the complete file as developed in ED for Windows.

Figure 24.8 : The ED for Windows screen showing

Compiling the Applet in ED for Windows

Because myapplet.class is dependent upon myCanvas.class, you need to compile myCanvas first. Therefore, make the mycanvas window the active window. Click the leftmost button on the Java toolbar to run the javac compiler against this code. Unless you modify the default options, ED saves the most recent changes to the file before compiling.

Compilation errors are displayed in the standard outbox. This is a new window which opens at the bottom of your screen. Double-clicking on an error causes the portion of the code where the error occurs to be highlighted. You can edit that line and then recompile. Be careful in compiling-make sure that the window containing the code is the active window when you press the compile button.

If the window containing the source code is not the active window when you select the button to run the javac compiler, unexpected results occur. If a dialog box is active, you don't get any response. If the output window is active, you get an error message from the Java compiler indicating that it is being passed an invalid file.

When you have successfully compiled, switch the active window to and compile it. Obviously, in larger projects it could become difficult to track which portions of the source have been compiled and which have not. However, if any of the .class files are missing the javac compiler itself attempts to locate the .java files and compile them.

Running the Applet in ED for Windows

Now you just need an HTML file to run the applet. Open one more new file and save it as myapplet.html. Open the skeletons, or if you still have the dialog box open, click the Rebuild button. You see a list of HTML skeletons. Scroll down, find the Basic HTML Page, and insert it in the new file. Replace the title with "myapplet Example." Select the body text and delete it. Find the Skeleton Applet skeleton in the Java category and insert it in the body of the HTML file. Change the code value of the applet tag to read myapplet.class, then remove the param name tag and save the file.

Having created the HTML file, set as the active window. Select the fourth button from the left to run the applet viewer. Be sure that is the active window when starting the Applet viewer (see Figure 24.9). This causes the viewer to look for the file myapplet.html.

Figure 24.9 : ED for Windows running myapplet.

Alternatively, you may select Tools|Programs and select Java Applet Viewer from the choose list in the dialog box. You can check the paths for each of the commands by editing them in the dialog box that results from the Tools|Programs menu option. Figure 24.10 shows the edit dialog box for configuring the applet viewer. Press Run to run the Applet Viewer or press Edit to examine the paths and parameters that are used when the Applet Viewer is invoked.

Figure 24.10 : ED for Windows screen showing Tool dialog box.


ED does not directly support runtime debugging. However, the JDB can be added as an available tool. To do this, select Tools|Programs to display the Tools Dialog Box. Click the Add button. Enter a name for the new tool. For the command line, enter the following:

d:\java\java\bin\jdb <File>

Give the working directory as <PATH>. Click OK to save the setup or Run to run the debugger.

Creating the Application in ED for Windows

Before creating the application, you can set up a skeleton for a generic application. This saves time in creating this and future applications, each of which will have the same basic structure.

To create a new skeleton, select Options|Language Words & Templates from the main menu. In the dialog box, select Java as the language. Scroll down to the templates section and look for the Programs heading. At the bottom of this section add the following code all on the same line.

genap import java.awt.*;
\n\npublic class GenApp extends Frame {
\npublic GenApp()\n{
\n}\npublic static void main( String args[] )\n{
\nGenApp localGenApp = new GenApp();
\\n}\u} Programs.Generic Application

In this case, genap serves as a marker for the new skeleton. The portion of the code from import through the last } specifies the code that will be inserted for the template. The word Programs designates that this skeleton will be listed under the category Programs and the following word, "Generic Application" is the name of the template.

The \ is used to indicate formatting options. The \n indicates a new line and \f indicates where the cursor will be after the skeleton is inserted. For more information concerning formatting and template creation, use the Help menu option in ED and look under Template creation, Template escape sequences.

Close the window and save the changes to the template file. You can now use your new template just as you would any of the templates which came with ED.

Setting up the Application in ED for Windows

To begin to create the application in ED, open a new editing window using File|Open. Save the file as Insert the skeleton code you just created by opening the skeletons dialog box, scrolling down to Generic Application, and clicking insert. After adding the generic application, the cursor is in position to add the title to the frame. Add this title and you have a basic application.

To enhance the application, do a search and replace to substitute myapplication for GenApp throughout the file. Go to the top of the file and add a blank line. Then use the skeletons to insert an appropriate header comment. In the constructor for the application, add the lines to display the canvas, label, and button.

Block cut and paste allows stream, column, or line mode, all of which can be handy for cutting and pasting large chunks of formatted code.

Having the button in the application requires an event handler. Add the method handleEvent() in the following manner. Type pub and press the spacebar. Notice how Ed completes the word. Next, type bo and press space. A menu listing appears, enabling you to select boolean as the expansion value. As you continue to type in the code for the handleEvent method, notice the different ways in which ED can help you complete the coding with less typing.

When all of the code has been entered, save the application. You are now ready to compile and execute the application.

Compiling and Running the Application in ED for Windows

Compiling the application in ED is just like compiling the applet. Use the fourth button on the toolbar to run the javac compiler against the active window. Use the second button from the left on the Java toolbar to run the application via the Java interpreter.

ED supplies Tips on Startup, an easy and painless way to learn more of the features of the environment.

ED has advantages for developers who often switch between languages. It can be used with most popular programming languages and compilers, enabling the programmer to continue working in a familiar environment even when switching projects. The class hierarchy browser and skeletons help to provide reminders of the correct syntax and features of a particular language.

Object Engineering Workbench

Innovative Software's Object Engineering Workbench for Java is a graphical editor and hierarchy display. It is useful for object-oriented design and development. This environment is set up to prominently display the relationships between classes.

Installation and Setup of OEW

An evaluation copy of OEW can be downloaded from You need to download the executable and then do a separate download for the .dll's.

OEW is slightly more complicated to install than the other two environments, mostly because it does not include an installation program. You need to create a directory for the program, unzip the DLL files, and put all the files in the directory. If you want a program group, you need to create it. Run the program by starting the file Oew.exe.

OEW has a number of utilities for creating and editing make files, but does not include a make utility. You need to locate and install make to use these options. Fortunately, OEW does enable you to configure the make tool to point to any make utility.

The Help information included with the environment is mostly directed toward the C++ environment. There is some online documentation concerning the Java environment, which is helpful to read before you try to use the environment itself.

Creating an Applet in OEW

Each applet or application developed in OEW is part of a project. Within a project, objects are created and properties are associated with each object. OEW then generates code for each object based on the definitions and properties.

Setting up a Project in OEW

To start a new development project in OEW, you need to create a *.oew file to hold information about which classes belong in the project. Select File|New and a New Object Base dialog box is displayed. Use the select button on this dialog box to display an Open file dialog box. In the Open File dialog, select the filename myapplet.oew, choose the desired directory, and press OK. Press OK in the Object Base dialog to create the new file. You are now ready to begin to create the applet.

Entering and Editing Code in OEW

To simplify entering the new classes, maximize the No View-Inheritances window. At any blank space in this window, press the right mouse button. From the resulting drop-down menu, choose the first option, New class. A dialog box displays where you enter the name of the class, my applet. When you select Add in the dialog box, the new class appears as a box on the display.

You need to edit the default definition of the new class. To edit the class, move the mouse pointer until it is over the box containing the class and press the right mouse button. From the resulting drop-down menu, select Edit class. In the box labeled modifiers, type public. Close the dialog box.

Methods and objects within each class are called slots in OEW. To add the init() method for the myapplet class, use the right mouse button to click on the class and then select New Slot... from the menu. A dialog box is displayed-here you can add the name of the slot, the type, and the access level. The values to enter are init, method, and public. Figure 24.11 shows this dialog box with its contents.

Figure 24.11 : Adding the init() method in OEW.

When you have entered the values shown, click the More button in the dialog box. An additional dialog box displays where you can add the code for the init() method. You do not need to add the opening and closing braces when entering methods in OEW. After entering the code, click OK to close the dialog and save the code. Click OK in the original dialog to close it and add the method.

What you have done so far does not actually create any code. When you have defined all of the classes, you generate the code, compile and run it. This can be very useful if you are in a design stage where you are defining objects, but are not yet ready to put source code behind all of the objects. You also can generate files to contain the code and enable the code to be entered by others. Existing code can be parsed and added to a project.

Having finished defining the class myapplet, you can move on to create the myCanvas class. The class is added in the same manner as myapplet. Be sure to set the class modifier to public after creating the class. In addition to using the right mouse button, you can add a new class by selecting Edit|New class on the main menu.

Before you create the methods for the myCanvas class, you need to have an Image object available to use for a class reference object. You must import the source to add the class to the diagram. From the main menu, select Source|Import source code. The dialog box Select Files to Import displays. In the dialog box, select Add to display the dialog box titled Open.

In the Open dialog box, locate the source for java.awt.Image and double-click it. Because the Open dialog box remains until you close it, go ahead and add java.awt.Canvas and java.applet.Applet, which you need to show the inheritance in your new classes. Click cancel to close the Open dialog box. The Select Files to Import box should now have three files listed in it and appear as shown in Figure 24.12.

Figure 24.12 : Importing source files in OEW.

Select start to load these files. When the dialog box closes you see the new classes displayed on the screen. Using the left mouse button, click canvas and drag to draw a line to myCanvas. This line represents the inheritance relationship. Use the left mouse button to draw a line from Applet to myapplet. Notice how the classes move to accommodate and highlight the relationship. If you want to see the methods available in either the Applet or Canvas class, you can use the right mouse button to show the slots for these classes, just like a class you create.

Now you are ready to create the slots for the myCanvas class. Using the right mouse button, click on myCanvas and select Show Slots. This sets the screen to display the slots as they are added to the class.

To add the reference variable, click on myCanvas with the right mouse button and select New slot. Give the slot the name localImage. Use the drop-down list box to select reference as the slot type. The access should be set to protected. Select more and another dialog box appears, enabling you to select the type of reference. Select java.awt.Image and click OK to close the dialog. If java.awt.Image is not available, review the procedure for importing classes. Click OK to close the original dialog box and add the slot. The new slot should appear in the myCanvas class.

To add the constructor, create a new slot using the right pull-down menu. Type the class name as the slot name and notice that the type defaults to method and the access level defaults to public. Click more to generate the next dialog box. Here you add the parameter as Image theImage and add the code for the constructor. Notice that there is no return type. Close the dialog boxes when you are finished. This method should now be listed under the reference variable as part of the myCanvas class.

The paint() method is added in the same fashion as the init() method. Open a dialog box to create a new slot. Enter paint as the name, method as the type, and public as the access level. Click more and enter a return type of void, the parameter Graphics g, and the line of code for the paint method. Close the dialog boxes and verify that the method has been added to the class. Figure 24.13 shows how the screen appears after all of the classes and slots have been added.

Figure 24.13 : Classes and slots for myapplet as displayed in OEW.

You are just about ready to generate the code for this project. You need to edit the header files first. These create the portion of your files which appear before the class listings-specifically, comments and import statements.

To add the needed import statements to the header files, go to the main menu and select Source|Modules. On the resulting dialog box, select myapplet header and click Edit. Click the myapplet entry so it is highlighted. This means that the entries you are adding appear just before the myapplet entry. Select New|User defined entry and in the resulting dialog box type the following:

import java.awt.*;

Click OK to close this dialog box. In the Edit Module dialog, select New|User defined entry to display another entry dialog box. In this one, type the following:

>import java.applet.Applet;

Close this dialog and the Edit Module dialog. In the Edit Modules dialog select myCanvas header and click Edit. Just before the class declaration define a new entry and add the following line:

import java.awt.*;

Close the dialog box, the Edit Module box, and the Edit Modules box. You are now ready to generate the source code.

To generate source code based on the classes you have defined, select Source Generate all from the main menu. A dialog box displays, showing the two source files that will be generated. Click OK to generate these source files. Once you have generated the source files you may edit them by selecting File|Edit from the main menu.

When you are satisfied with the source code that is generated, you will want to compile it into an applet. OEW enables you to generate a makefile and use it to compile your applet. Generate the makefile by selecting Make|Generate makefile on the main menu. Before using the makefile, select Make|Make options and verify that the make command points to a valid make program on your computer. To compile the applet, select Make|Make program from the main menu.

An additional window appears at the bottom of the screen showing the results of the compilation. Correct any errors which appear. Pay careful attention to the order of items in the headers, as this affects how the code is generated. You can change the order of the headers by selecting and moving them. You also can select and move slots so that your reference variables are at the top. It may be helpful to look at the actual source code to pinpoint any errors. After fixing the errors in OEW you need to regenerate the source code before compiling.

OEW does not automatically create an .html file. However, you can select File Editor to bring up a dialog box of files to edit. Click the Create button and enter the HTML file in the editor. Use File|Save As on the main menu to save the file as myapplet.html in the current directory.

To launch the applet select Make|Execute and type appletviewer myapplet.html in the dialog box. If the applet does not display correctly, look in the DOS box to see the error listing. Figure 24.14 shows the screen display with the applet running.

Figure 24.14 : myapplet running in OEW.

Creating the Application in OEW

Creating the application in OEW is very similar to creating the applet. You need to create a new project for the application. Click on File|New and create a new file named myapplication.oew.

Setting up the Application in OEW

Use Edit|Copy and Edit|Paste to move the Canvas and myCanvas objects to the new project. Next, import the Java source file for the Frame object.

When copying classes from one project to another, be sure to copy any super classes or the class in your new project is marked as a library class.

Create a myapplication object that is inherited from Frame. Enter the constructor, the handleEvent method, and the main method as slots in the myapplication class. Be sure to check the static box to indicate that the main method is static. Remember to make the class myapplication public.

Compiling and Running the Application in OEW

Before you can compile the application, you need to regenerate the makefile so that it contains myapplication information as opposed to myapplet. Select Make|Generate makefile to accomplish this, then choose Make|Build program from the main menu.

After compiling the application, you can run it in OEW by selecting Make|Execute Program and typing java myapplication. Figure 24.15 shows the application running in OEW with its class structure shown in the lower part of the screen.

Figure 24.15 : myapplication running in OEW.

The OEW environment provides an excellent means for seamlessly merging object-oriented design into code development. Classes can be defined at one point, methods added at a later point, and the methods can be implemented when the design is complete. OEW also makes it easy to integrate existing classes into new projects.

Comparison of Environments

The table below gives a comparison of some of the key features of the integrated development environments which are described in this chapter. Each of these products is being improved, so features not listed here may be added in the near future.

Table 24.1. A comparison of some of the features of the environments described in this chapter.

FeatureCafeED OEW
Compilation errors linked to codeYes YesNo
Automatic Save before CompileYes YesYes
Run appletviewer within environmentYes YesYes
HTML file assistanceYes YesNo
Launch Netscape within environmentNo YesYes
Runtime debuggingYes ConfigurableNo
Tips at startupNoYes Yes
Template creationNo YesYes
Class hierarchy browseravailable in full versionYes Yes
Class editoravailable in full versionYes Yes

When choosing a development environment, you should carefully consider the features that are important for your development effort. If your environment needs to support both design and coding, you need to examine environments with that in mind. If your design is complete and you want to generate code as quickly as possible, look for an environment that will enable your programmers to work as efficiently as possible.

One important criteria to efficiency is having an environment with which the developers are comfortable. If you are a C++ programmer and have an environment you are used to working in, see if that environment has been enhanced or duplicated to support Java development. Before purchasing a development environment, be sure to see if it supports multiple developers, if it will run across a network, and how it will integrate with your source code control system.

Other Products Under Development

There are many other IDEs available for Java and new ones are being added at a remarkable rate. Review sites such as

for an online list of new products. As this book is going to press there are several noteworthy additions.

Borland's Latte

Borland is expected to release Latte as a Rapid Application Development product for Java. The release is scheduled for the fall of 1996. Latte promises to include visual application development, secure cross-platform application deployment, JDBC support, and an open extensible architecture to support code reuse. Latte also plans to support Borland's Interface Database by providing a JDBC driver and integrating the database with Latte. Borland is using Java to develop a new product named InterClient. InterClient will give Java applets and applications more powerful and flexible database access capabilities than the JDBC alone.

Latte is scheduled to be released in the fall of 1996 and minimum system requirements are not yet available. More information on Latte can be found at

Microsoft's Jakarta

The Jakarta product has not yet been released by Microsoft. It promises to incorporate the ActiveX components developed by Microsoft into the Java applets. This idea has a great deal of potential, especially for organizations that already make use of Microsoft components in their development.

Jakarta is due to be released in the fall of 1996 and system requirements are not yet available. For more information on Jakarta, visit

Sun's Java Workshop

The Beta version of Sun's Java Workshop is available for downloading from Sun. This product is clearly developed specifically for Java and is robust and easy to use. The system includes a project manager, a source code editor, a build manager, a source browser, an applet tester, and a debugger. It appears well thought-out and should be useful for developing Java applets.

The system requirements for Windows 95 include:

Intel 90MHz Pentium or higher system
24 MB memory
45 MB disk space

To download a copy of Sun's Java Workshop visit


If you are working on a Macintosh, then Roaster from Natural Intelligence seems to be the choice development environment. Version 1.0 of this product has been released, and the product has received many good reviews. Roaster groups files into projects, provides a source code editor, and a debugger. It enables you to run applets on the Macintosh using the Roaster Applet Runner. Natural Intelligence has written their own Java compiler. Roaster includes both the compiler developed by Natural Intelligence and the Sun compiler.

The minimum system requirements for Roaster follow:

68030 or greater processor
8Mb of RAM
System 7.1.2 or later (7.5 or later preferred)
CD-ROM drive to install the software

For more information concerning Roaster, visit



This chapter surveyed a few of the many development environments that are beginning to appear for the Java language. They provide a tremendous improvement over plain text editors. These environments are useful for creating both applets and applications and an example of each is presented in the chapter.

This chapter does not begin to provide exhaustive coverage of the many features available from each of these products. However, having read the chapter you should feel comfortable getting started with each of the products. You only truly learn the products by using them. The beta versions of these applications were evaluated in this chapter, so be sure to check for improvements and additional features in the near future.