Skip to main content.

Web Based Programming Tutorials

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

Web Programming Unleashed

Chapter 6 -- Java Development Environments

Chapter 6

Java Development Environments

by Dan Joshi


CONTENTS



This chapter explores how to write programs more effectively in Java. In the last several months, many major software development companies have been designing Java development environments for programmers to work in so that programmers would not need to have a text editor and the Java Developer's Kit. This chapter gives you an overview of several of these integrated development environments (IDE) that have greatly improved on the Java Developer's Kit (JDK).

NOTE
An integrated development environment is one program that contains several tools. Each of these tools (for example, a debugger and class viewer) helps you throughout the development cycle as you create or modify a program. Because integrated development environments are GUI-based, they are easy to use, and because these environments usually contain many tools, they are extremely useful.

The Java Developer's Kit is the first and probably the most wide-spread development environment currently available for Java. It is merely a set of command-line tools in which programs authored in a text editor are saved in ASCII format. These source files are compiled and debugged using command-line executables provided with the Java Developer's Kit. The Java Developer's Kit is the first topic discussed in this chapter, but you learn other environments such as the Java Workshop, Symantec Café, and some of the newer Internet-related tools from Borland. These newer programming environments are based on the integrated development environment paradigm. In these new environments, everything is designed around a GUI form. If you are a programmer new to Java, I hope that by the end of this chapter you will be able to make an informed decision about several of the major environments available. On the other hand, if you are a proficient Java programmer, you will have a better understanding of the pros and cons for each of these new environments.


NOTE
Throughout this chapter, there are three types of terms to describe Java-compiled classes. An "applet" is an Internet-based Java class file. A Java "program" is a stand-alone Java class file. The term "application" refers to both Java applets and programs.

Before beginning, I should point out several high-level points, particularly your knowledge of Java that is assumed in the chapter and what will be presented. First, I assume in this chapter that you have an understanding of Java and, in some cases, an understanding of C/C++. If this is true of your skill set, continue reading this chapter. If this is not true, however, review Chapter 7 "Introduction to Java," and Chapter 8 "Java Programming," and then return to Chapter 6because those chapters give you an introduction to Java language syntax, building basic Java applets, and comparing Java to C/C++.

Second, I highly recommend that you have the development environment available to follow along for each of the environments discussed in this chapter. This chapter is littered with notes, warnings, and figures on how the environments look and how they respond to various real-life programming situations. Nonetheless, in some demonstrations (for example, the Java Workshop), you actually go through the process of writing a sample applet. Finally, note that all of the environments you learn in this chapter are installed and tested for the Windows 95 and Windows NT platform, primarily because Symantec Café does not have a non-Windows version for its Java integrated development environment.

Java Development Environments

One of the most intimidating things about Java when it was first released was the fact that there were no "modern" integrated development environments with which to compile Java-related programs. For veteran programmers, that was not an issue, but for the newer programmers who might have never authored code in a text editor, it made Java appear very intimidating. As a solution, many of the major software companies started designing a kind of proprietary Java development environment to make it easier in which to code. As a result, this chapter is designed to discuss some of those major development environments.

This chapter explores the strengths and weaknesses of each of the development environments. To start off, you learn the Java Developer's Kit as an initial place to break ground. After all, every one of these new integrated development environments that is covered is based on the original Java Developer's Kit. Also, the Java Developer's Kit is what you will use in the next two chapters to design and run sample Java programs.

The Java Developer's Kit (JDK)

You use the Java Developer's Kit (also known as the JDK) in the next several chapters to test and develop all of the programs and applets for Java. The JDK was chosen primarily because most Java programs are very simple and the JDK's availability gives the greatest flexibility. The JDK contains a full copy of the Java language, including a complete set of all built-in classes used in Java. The JDK also contains all the source code for these built-in classes. Suffice it to say that when you download the JDK, you have a fully functional, object-oriented Java programming language. However, you do not have a nice front-end environment in which to develop, nor an Internet browser to test your Java-powered HTML pages. Instead you get a program called the appletviewer that can read information only inside the <APPLET> tag in an HTML page.

NOTE
For more information on using HTML tags with Java, see Chapter 8

In fact, with the JDK, you really don't get any front end at all. All code must be written in some sort of proprietary text editor or word processor that can save to ASCII format. To do just about anything in the JDK, you must write code. In other words, with the JDK, you do not have any wizards, toolboxes, or Java code generators to point and click your way to Java computing.

The latest version of the JDK at the time of this writing is version 1.0.1. You can obtain this version for free from Sun's home page at the following site:


http://java.sun.com/download.html

The JDK is available for Windows 95, Windows NT, Sun's Solaris 2.4 or higher, and now the Macintosh. Although each of these JDK versions is extremely similar, there might be some minor differences between them. To remain consistent with the rest of the chapter, we will use the 32-bit Windows version of the JDK (that is, the JDK for Windows 95 and Windows NT). Installing the JDK for 32-bit Windows is fairly simple. Download the self-extracting file from the preceding address, run the self-extracting executable, and it will do the rest. (Let me be the first to pass my condolences to those who were expecting the InstallShield wizard.)

NOTE
InstallShield is a third-party product (from InstallShield Corp.) used to standardize the installation of a program. Its features include a completely point-and-click interface with which users can move through the installation of a program and an uninstall utility with which users can easily remove the product from their systems.
InstallShield is rapidly becoming the industry standard for software companies that use it to guide their users through installing their programs. The InstallShield is featured in the Java Workshop, Symantec Café, Borland C++ 5.0, and most likely it also will be bundled with Borland Latte when it is officially released.

When you have successfully installed the JDK, you are ready to begin. The JDK 1.0.1 compressed is about 4.4MB; after running the self-extracting executable, it should take no more than 7MB of space.

NOTE
One advantage of the JDK over all the integrated development environments is that it takes the least amount of space when it is uncompressed.

How To Use the Java Developer's Kit

Using the JDK can be pretty simple. Figure 6.1 shows the JDK directory structure after installing it on the E:\ drive.

Figure 6.1 : The Java Developer's Kit directory structure.

After you run the JDK, you can see that it creates a directory called ..\java. As you can see in Figure 6.1, the first thing to notice in the ..\java is the file src.zip. This file contains the zipped source code for the JDK classes.

NOTE
All built-in Java classes are written in Java.

Next, you learn the demos that come with the JDK. In Figure 6.1, you see the subdirectory ..\demo. The demos located in that directory can be invaluable tools in learning about the language. Also, the JDK is set up so that a browser can locally access it. A file called index.htm is in the ..\java directory. Load that HTML page in a Java-compliant browser (for example, Netscape 2.0 or later). Figure 6.2 shows index.htm loaded.

Figure 6.2 : The index.htm file in the Java Developer's Kit.

Referencing Figure 6.2 in index.htm, you see a link to applet examples. Click this link to bring up a directory listing of all the demos that come with the JDK. Click the directory animator to see the directory containing all the pertinent information for the animator applet. Finally, load the file example1.htm to load the animator applet shown in Figure 6.3.

Figure 6.3 : Animator example (..\java\demo\animator\example1.htm).

If you look at the bottom of the applet, you will see a link to the source code for this applet. In the animator example in Figure 6.3, this opens up the file animator.java, located in the ..\demo\animator subdirectory, which shows the source code for this applet. Although this is not exactly a full-blown tutorial with all the bells and whistles available in the other integrated development environments that are demonstrated in this chapter, these examples give you valuable information for learning Java.

The next directory in Figure 6.1 that you learn briefly is the ..\java\lib directory. Looking in the ..\lib directory, the first thing to notice is the javac.properties file. This file is saved in a viewable format. Inside, you will see a long list of all the error messages from which the Java compiler draws during the compilation process to describe the errors it encounters when compiling your Java program. There is also a file called javai.lib, which is a library file used by the interpreter. The next file, javai_g.lib, is another copy of the javai.lib except that it is used to debug your Java programs. You learn more later in this section.

NOTE
Any executable with a _g at the end of its name in the JDK means that it is a nonoptimized version of the same executable designed for use with the Java debugger.

The last file is classes.zip. If you look at the readme file located in the ..\java directory (refer to Figure 6.1), it says that you should not unzip this file. It is used by the Java compiler in this compressed form and contains the compiled class files for the built-in classes in Java.

The next and probably most significant directory for the JDK is the ..\bin directory, which contains all of the command-line executables used to develop Java programs in the JDK.

The ..\java\bin Directory

The ..\java\bin directory contains all of the executable tools used in the JDK as well as the DLLs that are used by these executables. Note that some of the tools are designed specifically for advanced programming techniques and are discussed only briefly.

NOTE
A DLL or Dynamic Link Library is simply a compiled function that programs can call.

The javac.exe File

You will see many executables in the directory ..\java\bin. The first, javac.exe, is probably the most important tool in the JDK because it compiles the Java source code files into Java bytecodes. You will have a chance to work with the Java compiler in the next two chapters. The source files must be named with the extension .java when they are compiled by javac.exe. By default, all files compiled will be placed in the same directory as the source file. However, you can use javac.exe to compile programs and place the class files in another directory by using the -d option:


javac -d e:\test c:\ABClass.java

In the preceding line of code, you see that by using the -d option on the fictitious class ABClass.java, it will compile the class file and place it in the e:\test drive. The javac.exe also can utilize the -g option, which gives you the capability of creating debugging tables.

The parameter that can be passed during compilation is the -O (the letter not the number) option, which can be used to optimize your compiled code.

NOTE
Specifically, the -O option optimizes your Java application by in-lining all static, final, and private methods. In C/C++, an in-line function is a small function whose code resides in the line of declaration (or prototype) rather than being called externally by the program. Efficiency is the advantage of in-line functions in C/C++ and Java because the application does not spend several cycles externally calling the function when the application is executed.

The next parameter I should mention is the -verbose parameter, which causes the compiler and linker to print out information about the source files being compiled, the classes being loaded, and the length of time it took to do each process.

The -nowarn parameter tells the Java compiler to skip over warnings instead of printing them out and stopping compilation.

NOTE
A warning is an error found by the compiler that does not merit immediate attention to run the Java program.

The last parameter is the -classpath parameter. In the compiler, this option specifies the path in which the compiler should point to reference classes in Java. The following shows a breakdown and summary of all the available compiler options in Java:

-classpath <path> Specifies the location of class files to the compiler.
-d <directory> Specifies the destination directory for the compiled class file.
-g Enables the creation of debugging tables.
-nowarn Disables warnings.
-O Optimizes the code by in-lining static, final, and private methods.
-verbose Displays information about the source files being compiled, the class files being loaded, and the length of time each step took.

The java.exe

The java.exe is the interpreter for compiled Java programs. The interpreter will work only with compiled class files, not the source files. Do not specify the .class extension for the class file that you want to interpret. The Java interpreter works by converting the bytecodes of the specified class file to processor-specific machine code so the client's system can execute it. An example of using the interpreter on the fictitiously created class ABClass.class follows:


java ABClass

The interpreter essentially looks for two things: the file passed containing compiled bytecodes and the location of the method main from which it can execute the body of the Java program. As in the javac.exe compiler, the interpreter also has the same functionality with the -classpath option. Also note the -debug option in the Java interpreter. This option enables the Java debugger to attach itself to this session, which is very useful in debugging programs.

Another useful option is the -cs option, which actually causes the interpreter to compare the loaded class file to the loaded source file. If the source file has a more recent date, then the -cs option will recompile that file. This option can be very useful in making sure that the compiled files you are interpreting are the most up-to-date classes.

Next, note the -noasyncgc option, which toggles off the asynchronous garbage collection for this session. When this tool is activated, Java will not run a separate thread for garbage collection. In fact, Java will not run garbage collection at all unless it runs out of memory completely or the program explicitly calls to activate it. Along the same lines of garbage collection is the option -verbosegc. This parameter is very similar to the -verbose parameter mentioned with the javac.exe compiler except that it is designed to display information about the garbage collector whenever it has free memory. The following gives you a quick reference for the garbage-collection-related options with the Java interpreter:

-noasyncgc Turns off the asynchronous garbage collection.
-verbosegc Prints information pertaining to memory freed by the garbage collector.

NOTE
For more information on the garbage collector, see Chapter 5 "Java and the Internet."

Other parameters that are available are -verify, -noverify, and -verifyremote. These parameters all are made possible because Java utilizes bytecodes. The -verify and -noverify toggle on or off the verification of all Java code. The -verifyremote parameter, which is the default if nothing is explicitly specified, verifies only code that is loaded into the system via a special class loader. Use the following list as a quick reference to this set of parameters:

-noverify Disables all bytecode verification.
-verifyremote Enables bytecode verification for classes loaded into the system by a separate class loader.
-verify Enables all bytecode verification.

Another parameter available to the Java interpreter, -version, specifies the version and build for the compiled class passed to it. This parameter is very useful in determining the version of Java in which your class file was compiled. For example, currently you are using the JDK 1.0.1 to compile your classes. The following code is an example of what to type to find the version for the class ABClass.class. The second line is an example of the output from the interpreter.


java -version ABClass.class

java version "1.0.1"

The next set of options you will learn briefly are the parameters to specify the stack and heap size for a Java session.

NOTE
A stack and heap are special regions of reserved memory in which programs can store data (usually local variables). In general, the program, operating system, and microprocessor all can have one or more stacks assigned to them. In the case of Java applications, two stacks are maintained for each thread it is running: one for the C code (referring to any native code from native methods that are used in your application) and another for the Java code.

NOTE
The data structure for a stack is organized as a LIFO (last in first out) list format. Therefore, the last data item added to the stack will be the first item used.

The following list shows the parameters pertaining to specifying the stack and for what they are used:

-mx <number>Specifies the maximum size for the Java heap. The default is 16MB.
-ms <number>Specifies the start-up size for the Java heap. The default is 1MB.
-ss <number>Specifies the maximum C stack size for this thread that is used for any native code your Java application might contain.
-oss <number>Specifies the maximum Java stack size for this thread.

NOTE
You must specify a number after each parameter when you pass values to the various stack options. The interpreter will assume that the specified number is in bytes. However, if you want to specify a larger value (that is, a value in kilobytes or megabytes), then append the letter k for kilobyte or m for megabyte to the numerical value (for example, 512k or 10m).

At this point, you have learned all of the pertinent options and syntax for the Java interpreter. Still, you can use a few more parameters with java_g.exe that do not come with java.exe. These special parameters deal specifically with debugging your Java programs. The first two are -t and -tm, which deal with printing a trace on the screen. The -t parameter, for example, prints out an instruction trace while -tm prints out a method trace. Also, -prof prints out profiling data about the specified session to the file java.prof. The last list for this JDK tool, which specifies all of the options only available to the java_g.exe file, follows:

-t Enables instruction tracing.
-tm Enables method tracing.
-prof Prints the profiling data to a file called java.prof.

NOTE
All options introduced in java.exe are also available to the debugging version, java_g.exe.

The Java Debugger

The jdb.exe file is the JDK's debugging tool, which is attached to an interpreted session. This debugger is designed to attach itself to an interpreted session and execute commands. A full description of this tool is beyond the scope of this book, but it is important to note that you can use jdb.exe to help debug your program. Note, however, that working with jdb.exe has many rewards, because it can enable you to go through your program and execute one line of code at a time, enabling you to set break points to help you see exactly what your code is doing at any time. An example of how to use the default syntax for the debugger follows:


jdb ABClass

One major weakness in the JDK is that it does not have a visual debugger. Instead, it uses the command-line debugger jbe.exe.

javah.exe

Before we can discuss javah.exe and its function in the JDK, how to effectively use the javah.exe tool, or move forward with the discussion on the JDK, we should digress and discuss Java's native methods.

NOTE
Native methods are C functions used in Java.

Native methods are an advanced programming technique. If you are new to Java or have no experience with C/C++, it is a topic you might want to avoid. Native methods are more complicated than they have to be and are not really that useful except in rare cases. If this has piqued your interest, however, then continue with the following paragraphs for a quick description of native methods and using javah.exe to create native methods.

Native methods give you the power to link C programs to your Java programs. Of course, if computer programming were that simple, then computer programs wouldn't have bugs. Realistically, though, when you use native methods, you lose the ability to port Java programs to multiple platforms. Second, you cannot create applets with native methods because of the security risks involved. Internet browsers do not support native methods, which means that you cannot use native method technology for any kind of Internet-related solution. Third, your Java application (not applet) cannot verify the native code because the native code cannot be compiled to bytecodes.

In those few cases in which using native methods is the only solution, you will need to declare a method, place the keyword native in front of the declaration, and end the method with a semicolon instead of a pair of brackets.


public native void myMethod();

That's all you need to do on the Java side. On the C side, however, you must create your function to implement the method myMethod. This is where javah.exe comes in because you might need to generate C headers from your Java-compiled classes so you can work with these classes in the native environment.


javah ABClass

The last directory shown in Figure 6.1 that you have yet to learn in the JDK is the ..\java\include subdirectory, which includes header files to help you implement your native methods. Writing native methods is not for rookies to Java. Furthermore, the programmer must have a deep understanding of C/C++ as well as Java. Frankly, native methods are so rarely used that they will not be mentioned again.

javap.exe

The javap.exe is a class disassembler; that is, it will take a compiled file and disassemble its bytecodes back into source code (ASCII form). The following list shows the options for this executable. Most options in the list have been discussed with the other command-line tools and a few new options are fairly self explanatory. One major problem with the Java disassembler is that in reality, it is difficult to pull source code from a compiled class file. Consequently, we won't spend much time discussing it.

-c Disassembles the code (that is, prints out the public method and fields for this program).
-classpath <path> Specifies the directory for javap.exe to look up classes.
-p Prints out the private and protected methods and fields of this class.
-verify Verifies the bytecodes.
-version Displays the build version of this class.

javadoc.exe

With javadoc.exe, a very useful documentary tool in the JDK, you can create HTML pages based on the proprietary classes from your source code. The javadoc.exe tool parses the source files of your classes. This parsing process can include specially designed comments placed in your code. You can include HTML tags in these comments and parse them to the resulting HTML page. It is very useful in creating HTML pages because it will help you and other programmers understand your code. The following is an example of parsing the source file for the fictitious class ABClass:


javadoc ABClass.java

If this line were executed, it would create a file called ABClass.html, an HTML file that you can view as a reference source in any browser. However, the following example exemplifies another powerful feature of javadoc.exe, in which you can pass HTML tags and comments to the HTML pages you create by writing specially designed comments in your code:


/**

*Below is a class I created:

* <PRE>

*     javadoc ABClass.java

* </PRE>

*

* @author John Doe

* @version 1.0

*/

In this example, the beginning and end of the comment is specifically designed to create a special HTML document that will comment on the method coming after it. For example, javadoc.exe uses the first line, /**, to generate the HTML page. Also, the javadoc.exe parser will recognize three parameters within this comment. The first is @param, a special setting used to place a comment just before the method in the HTML page explaining what it does; the @return description, which results in specifying a return for this method; and the @exception, which lists the available exceptions that this method can throw.

The end result is that with this new tool you will be able to generate well-documented classes on your source code. However, of all the development environments that you will learn in this chapter, the command line javadoc.exe is one of the most difficult to work with.

The Appletviewer

The last tool you will learn is the appletviewer. The appletviewer is used extensively in Chapter 8 Its primary function is to look for and utilize only the <APPLET> tag in the HTML page that is passed to it. This tool enables you to view your applets from its HTML page. The appletviewer generally has proven itself to be such a functional tool that it is incorporated into some of the other integrated development environments, such as Symantec Café.

NOTE
For more information and examples on using the appletviewer, see Chapter 8

Interestingly, when you first use the appletviewer with the JDK, it will create a directory called .hotjava, and in that directory is a file called properties (see Figure 6.4).

Figure 6.4 : Java Developer's Kit directory with the .hotjava directory added by the appletviewer.

In the .hotjava directory, you will see the file properties, where you can view and edit the properties for the appletviewer.

NOTE
Currently, all Java-compliant browsers do not enable you to access the client's computer to read or write files. However, the HotJava browser and the appletviewer have an optional parameter that gives the client the capability to specify access to its system. Along these lines, you can give the HotJava browser or appletviewer access by specifying a directory for the file to have read or write access to the Java applet. You can implement this by adding the following to the properties file:
acl.read=/java/bin
acl.write=/home/applet/file.fle

Java Development Kit Closing Comments

The JDK is not the friendliest environment in which to work, but it certainly is one of the most widely used and is probably the most stable environment in which to develop. Working with the JDK is also a very cost-effective solution because it currently is available for free from Sun. If you want to learn or instruct pure Java syntax, then the JDK will be your best choice. We will reference the JDK throughout the rest of this chapter and also will use it in the following two chapters for real-life demonstrations.

Symantec Café

Symantec Café is an IDDE (integrated development and debugging environment). Café is Symantec's tool that was designed to be the next step from Symantec's previous Java development environment, Espresso.

NOTE
Espresso is Symantec's wrapper utility for Symantec C++ and was designed to give owners of Symantec C++ the ability to develop Java programs in Symantec C++. It is being replaced by Symantec Café, which is a stand-alone Java Integrated Development Environment.

By the end of this section, you should be able to appreciate the Symantec Café as a very powerful tool to work with in Java. With Café, you can create Java applets and embed them into Web pages. You also can link Café with your existing Web browser (if you have one installed) to view these pages or use the built-in appletviewer to view them as well. Also, Café contains the full object-oriented Java functionality to create stand-alone Java programs. Unlike the Java Workshop, about which you learn a little later, Symantec Café has provided substantial enhancements to the original JDK. However, Symantec has grounded every change it has made to focus on the JDK. Symantec has not made any changes to the built-in class libraries that also come with the JDK.

With Café, you can easily customize just about everything. Probably the most powerful feature is Symantec's version of the Java compiler, a native compiler designed to be much faster than the javac.exe compiler that comes with the JDK. Symantec also utilizes its own DLL for interpreting Java programs, resulting in a much faster running time.

Symantec also sports a very powerful visual debugging tool. Café is the only Java IDE currently available that has a special parser that will parse your files and create a GUI-based debugging and viewing window. With this window, you can view your classes and debug your code with your mouse.

NOTE
Symantec offers a tool called Visual Debugger, which is a GUI-based debugging environment that contains parsed class files from your project. Not only can you point and click your way to debugging code, you also have the ability to control and debug each and every thread in your Java program individually because the Visual Debugger was designed for Java's multithreadedness.

In the visual design environment, Symantec Café has a Visual-Basic-like design environment with a drag-and-drop toolbox to design front ends in Java. Symantec Café writes the actual code for everything on the back end.

NOTE
Try using both mouse buttons on anything and everything in Symantec Café to gain access to tools available to help you.

Installing Symantec Café

Installing Symantec Café is very easy because it comes in a CD and contains the standard install wizard to help you through every step of the process. During the installation process, you can choose to install various groups of tools on your hard disk. If you choose everything, Symantec Café should require about 25 to 60MB, depending on the cluster size of your hard disk.

As mentioned at the beginning of the chapter, Symantec Café currently is available only for the 32-bit Windows environment. However, Symantec also is working on another version of Café for the Macintosh environment.

NOTE
Symantec is working on Caffeine, a Macintosh version of its Café.

Café Desktop

The Symantec Café gives you a highly visible work environment and enables you to create customized views of your workspace that will be saved when you exit the program and automatically reloaded when you return. The Symantec Café also enables you to create customized views for your workspace that you can reference by name. You can customize different layouts with the tabbed workspaces and create your own tabs and add them to the workspace tab. You have the ability to redesign completely your view of Symantec Café.

Café Views Palette

You could probably consider the views palette to be the control center for the Symantec Café. It is located to the right of the Workspace tabs. You can activate the array of buttons by double- clicking them or use them as a drag-and-drop icon bar to edit and debug your Java programs. For example, drag the source icon from the views palette around the center of the screen, let go, and you will see a new source file created exactly where you dropped the icon with your mouse (see Figure 6.5).

Figure 6.5 : The views toolbar.


NOTE
If you cannot find the calendar.prj file or the ..\samples directory, you probably did not direct the Symantec Café to install the demos during the installation process.

The Symantec Café comes with 41 sample projects and about 85 total examples. As a demonstration of Café, you will work with one demo called CALENDAR.PRJ. Open CALENDAR.PRJ by opening the Project command on Café's main menu bar. From there, go to ..\java\café\samples\java\calendar, which should display the project file calendar.prj.

NOTE
Like the Java Workshop, Symantec Café organizes its Java programs into projects controlled by files with the .prj extension (for example, calendar.prj). Unlike the Java Workshop, Symantec Café does not support the use of portfolios.

Symantec Café Express Agents

Symantec Café comes with two express agents. Express agents are wizard-like tools used specifically in Café. With the first express agent, called the Project Express, you can quickly create a new project using the point-and-click format. This way you can navigate your way through several screens with the ability to select source files and create new source files to begin your project.

The other express agent is the AppExpress agent, which helps you generate a new Java applet, program, or console. It will even get you started by generating some basic code based on your input.

You can access the Project Express by clicking the Project menu on Café's main menu bar and clicking New to invoke automatically the Project Express. The AppExpress can be found in the menu bar tools with the AppExpress button.

Café Studio

Possibly the most powerful tool in the Symantec Café is the Café Studio. With this very powerful visual resource editor, you can interactively create and edit menus and visual components using simple drag-and-drop techniques.

NOTE
For more information including a formal discussion on Java User Interface controls, see Chapter 8

NOTE
With the Visual Resource Editor in the Café Studio, you can design your front end visually. The Café Studio provides methods to handle events in the front end while automatically generating the necessary source code to be placed in your project.

You can access the Café Studio by clicking Resource and New on Café's main menu bar. Symantec Café actually creates a resource file, which will be discussed later, with our sample Java program calendar.prj, which you opened earlier. In the Project View, double-click the file calendar.rc in the list and a dialog box will open, asking you if you want to open the Café Studio. Click Yes and when the Café studio loads, highlight the item Form on the right side of the new window. An item Calendar "init" on the list box below the one in which you currently are working should be displayed. Right-click that item and choose the option Edit resource. Figure 6.6 shows what you should see on the screen.

Figure 6.6 : Caf Studio with the sample calendar.rc file open.

Looking at the main window in Figure 6.6, you see that you can design the form completely from the ground up. Also, looking at the properties tab window for this form, you can manipulate the general preferences for the form as well as the font types, sizes, and attributes for the objects used in this form. You can work with the layout as well as write code to handle events.

Resource Files in Symantec Café

When you save a form design using the Café Studio, it generates a proprietary resource file with the extension .rc (for example, calendar.rc). This file maintains all of the components, layout, and other pertinent information that the Café Studio used, but it is used only in Symantec Café as an intermediary to generate the Java source code for the actual designs in the Café Studio for the source files. In the end, your program will be entirely Java-based code.

NOTE
Also note that one reason that the Café Studio does not directly save information about the form designs in a Java source file is because (as you will learn in Chapter 8 in Java, you do not typically have the capability to specify exactly where all the Java controls and components are to be placed. Instead, Java uses a layout manager that follows a given format in which each object is placed relatively to each other. This is very useful in Java because the Java program can be ported to so many environments. However, this portability is not needed or wanted in the design stage of the form, which is why Symantec Café utilizes this resource file to enable you to specify more exact information of where you want to place objects.

Programmer's Editor

From just about anywhere, you can parse the Java source files and read all of the source methods imported by the project. Within the project settings, you can specify the target program type and any compile and debugging options. From the file in the project list, you can double- click a file to the open source editor with that file, and you can right-click a file to compile just the selected file.

NOTE
Symantec Café gives you the option of using either its native compiler, which is much faster, or the compiler bundled with the JDK.

Now look at some code in the calendar project file. Go to the Project View and double-click the file calendar.java. A window similar to that shown in Figure 6.7 should come up.

Figure 6.7 : Programmer's Editor example using the calendar.java file.

You can see that Symantec Café uses special colors to highlight various parts of the code. For example, all of the code in dark red signifies a comment and all of the code in blue is reserved for Java keywords. Café goes beyond just displaying various colors, however; Café also has linked visual tools to this code.

Symantec Café Parser

With the Symantec Café, you can have an object-oriented view of your code, especially through the use of its parsing technology and its visual class editors. Café utilizes a parser that is unrelated to the compiler. It runs on a separate thread in the background and automatically parses the changes that you make to your Java source code. This parsed code then is used by two tools in Café: the Class Editor and the Hierarchy Editor.

Class Editor

The Class Editor is a three-pane class browser that gives you a visual list of all of the classes in your program and a list of all the method and data members contained within each class. This tool is designed to focus on the abstract parts of your code, which means that it looks at your class methods and variables without displaying the actual implementation code in your Java program. As you burrow down into your classes, however, you can get to the source code to make changes in your code.

Once again, go to the Views palette and double-click the Class Editor icon. You will see three panes of information. The pane of the top left represents all of the classes in the sample project calendar. The top right pane shows all of the methods and variables for the selected class. The bottom pane is where the specified method's source code is displayed. You can open the source code for a given method in two ways: by right-clicking the method or variable then clicking the command Go to source or highlighting the method and double-clicking it. Open the default package as in the example in Figure 6.7 and double-click the method Action. The source code will open in the third pane and should look something like Figure 6.8.

Figure 6.8 : Class Editor example with the calendar.prj.


NOTE
Referencing Figure 6.8, the diamond colors next to each element indicate its access relationship. Green means public, yellow means protected, and red indicates that the access privilege to this element is private.

The Hierarchy Editor

The Hierarchy Editor is similar to the Class Editor except that the Hierarchy Editor is an architectural way to view your Java programs and any other classes that belong to the program. You can directly manipulate your program's inherit structure by dragging and dropping. Also, the Hierarchy Editor enables you to double-click a particular class to activate the Class Editor with that particular object opened.

Looking at the example with the project calendar, double-click the Views Palette icon that shows the Hierarchy Editor.

Figure 6.9 : The Hierarchy Editor in the calendar.prj.

The following sections briefly discuss several tools related to the Programmer's editor in Café that help in the design and debugging process.

The Thread View

The Thread View is a very powerful feature that Symantec included in light of Java's multithreadedness. With the Thread View program, you can suspend and activate threads in a Java program.

The Call Chain

The Call Chain displays all code modules and methods executed by an individual thread and displays the current execution point as well as the return points for each called method. With the Call Chain, you can follow the execution rhythm of your program.

The Watch View

The Watch View inspects the data in variables and objects. With Watch View, you can examine the values of class members and variables. Simply drag a module from the Call Chain into the watch windows and all variables accessible to that module are displayed in the window.

During the installation process, you will see that Symantec Café comes with a tutorial that demonstrates the very basics of Java as well as how to use the tools that come with the Symantec Café.

Symantec Café and the Appletviewer

Symantec Café, unlike Java Workshop, does not come with a built-in HTML viewer and does not have the Java Workshop's Web-centric focus. Instead, it is more geared toward the Symantec C++ design style for Java. The Symantec Café does come with the JDK's appletviewer built into it. It is invoked automatically when you click the command Execute Program in the Project menu bar. Let's compile the calendar project. Go to the Project menu and click the Build All button. Notice that the bottom window called Output will appear on the screen. The Output window displays the output of a text-mode program being compiled, parsed, or debugged. If errors are encountered during parsing, messages are displayed in the Output window. You can double-click the error message to open the source file and point to the trouble spot. At this point, build the calendar project (see Figure 6.10) and you should receive no errors.

Figure 6.10 : The Output window for compiling calendar.prj.

Finally, click the Project menu again and then click Execute Program to minimize Symantec Café and invoke the appletviewer with the Calendar applet loaded. When you exit the appletviewer, it will automatically restore the Symantec Café development environment (see Figure 6.11).

Figure 6.11 : Appletviewer of calendar.prj.

Symantec Café Closing Comments

The Symantec Café is a powerful integrated development environment, no doubt aimed at serious Java development and large-scale projects. It should receive an award for bringing Java to the next level of development because it can write code for you, pinpoint Java errors with its point-and-click debugger (in half the time as the command-line debugger in the JDK), and manage large-scale development projects with its project manager. Finally, its blazingly fast compiler makes the Symantec Café definitely worth a second look.

The Borland Internet Products

Borland currently is developing several Java-related products. The first product that has been released is Borland C++ 5.0. The other project will be a unique step in a new direction for the integrated development environment. This new environment, called Borland Latte, will be Borland's Delphi look-alike for Java.

NOTE
Delphi is a rapid program development (RAD) environment developed by Borland. Its syntax is designed for writing programs with fewer bugs, easy to understand code, and less time spent in development. What is the price for this euphoric development language? Efficiency. In general, a RAD environment will generate less-efficient programs because it is a higher-level language. However, this efficiency versus understanding statement is valid only in environments that were designed to provide companies with quick solutions to the modern client/server topology. Because Java is such a new programming language, it will be interesting to see whether Borland Latte will follow that same paradigm or be able to develop efficient Java code.

Borland Latte

Latte will focus more on the RAD environment than all other integrated development environments discussed in this chapter. Borland Latte probably will be available by the time you read this. At this point, one feature intended for the Borland Latte is a graphical debugger. Also, as with all the other integrated development environments, Latte will have a just-in-time (JIT) compiler. Other tools, such as a form builder to point and click your way through the front-end design stage (as in Café Studio), also are planned.

Borland C++ 5.0

Borland has released several other products that also deal with Internet (more precisely, Java) development. Borland has bundled these new tools with its new version of Borland C++ (5.0). One major quality behind Borland C++ 5.0 is that it goes beyond an integrated Java development environment and seamlessly integrates developing in C++ and Java so that one project can contain both types of code. Because Java and C++ are closely related languages, it is logical to design one comprehensive set of Java-based tools.

Two editions of Borland C++ 5.0 currently are available: the Borland C++ Development Suite and Borland C++ 5.0. The primary difference between the two editions (as related to Java) is that the AppExcelerator (Borland JIT compiler) is bundled only with the Development Suite edition. In the next few sections, you learn some of the other Java-related features that come with both editions of Borland C++ 5.0.

AppExpert for Java

The AppExpert for Java tool is designed to start a new Java program quickly. Just about everything in this wizard-based tool can be done with a few mouse clicks to create a custom program that will start you running. In essence, AppExpert for Java could be considered a Java code generator.

The Targetexpert Tool

The targetexpert tool lets you create Java projects with the click of a button. Because Borland has seamlessly integrated the two programming languages into one environment, this wizard-based tool will ensure that your environment is properly configured to create Java programs as well as C++.

The Borland Debugger

The key tool that Borland has designed for Java developers is the graphical debugger. This debugger is available in both editions of Borland C++ 5.0. A pre-release of the Borland Debugger, which can be downloaded and installed on top of the JDK, is also available. If you are interested in looking at the free pre-release Borland Debugger, go to the following site for more information:


http://www.Borland.com

NOTE
The Borland Debugger for Java is currently the only graphical Java debugger developed in Java. Therefore, it is the only graphical debugger available outside of the Windows environment.

Installing the Beta Borland Debugger

After you have downloaded the Borland Debugger, make sure that you have installed the JDK. Run the self-extracting executable in the ..\java directory in the JDK. The debugger might ask you if you want to overwrite some files; overwrite everything.

Preview of the Borland Debugger

In the Borland Debugger, you will work in one of several panes. The first pane on the left, the Call Stack pane (see (1) in Figure 6.12), shows function calls made to this point. It is interactive in that you can view details on various items by clicking them.

Figure 6.12 : The Borland Debugger with numbered panes.

The second pane on the right (2) is the Source pane. This pane shows the code of that class. Use your mouse to click break points in various lines of code.

The third pane (3) is the Variable (also known as the Context) pane, which shows you all of the arguments and local variables for this function. The Context pane is in a file-manager-type design where you can expand and collapse objects and subobjects to toggle between to view the information.

The fourth pane (4), in the lower-left corner, is the Watch Point pane. Use this pane to track a variable for its entire life by dragging and dropping it into the Watch Point pane.

The fifth pane (5) is the Console pane, which gives you high-level information about what is happening during the debugging process.

NOTE
The Borland Debugger has a feature called Hot Break that lets you specify break points while the program is running. Hot Break gives the programmer maximum flexibility.

The Borland Internet Products Closing Comments

Borland is definitely developing quite a few great products. At this point, the Borland Debugger is the only available Visual Debugger for Java that was written exclusively in Java, and Borland also has the only seamlessly integrated development environment for Java programming language with C++. Latte probably will be the biggest ground-breaking event in the Java-integrated development environment community coming from Borland. Latte will provide a Delphi-like development environment geared toward Java.

The last integrated development environment about which you'll learn is the Java Workshop. It, too, is completely unique with its Web-centric development environment.

The Java Workshop

The Java Workshop is Sun's addition to the Java visual development arena. It is uniquely designed as a development environment because it focuses on an Internet browser format. The Java Workshop enables you to create new applets and programs as well as author HTML pages. Hence, the Java Workshop gives you the capability to create Java-powered HTML pages all in one place. The Java Workshop also enables you to test the applets and programs in HTML pages that can be loaded in the program. One interesting feature coming to the Java Workshop is the capability to design custom HTML pages. At this point, however, that function is not supported. By the time you read this, though, the Java Workshop definitely should be officially released. At the time of this writing, the Java Workshop is in its advanced beta stage. The Java Workshop is geared specifically toward Internet/intranet development solutions. And yes, the Java Workshop was written in Java, so the Java Workshop should be available for any Java-supported environment.

Because the Java Workshop is a Web-centric development tool with added features, such as Web page authoring and applet publishing, which will be packaged with the released version, you will be able to focus the Java Workshop in an Internet/intranet solution during the development and testing process. Installing the Java Workshop should be fairly painless because it uses the InstallShield to guide you through the entire process.

NOTE
The InstallShield is also used with Symantec Café.

Note that the Java Workshop is a completely self-contained development environment, which means that you do not need to install the Java Workshop on top of the JDK. In fact, if you look closely you will see that the Java Workshop is actually more of a wrapper or shell around the original JDK, about which you learned earlier. If you look at the directory structure for the Java Workshop, you will see the subdirectory ..\JDK, and in there you will see the executables (for example, javac.exe) that you learned in the JDK.

NOTE
Because the Java Workshop does not use the JDK, it is recommended that you remove the JDK if you have it on your system before you install the Java Workshop.

Introduction to the Java Workshop

The first object to note in Figure 6.13 is the lighthouse on the right side of the window. Whenever the Java Workshop is busy (including loading HTML pages and compiling Java programs), the lighthouse will be animated just like a browser. Also, look at the icons in the panel at the bottom of the screen. Those icons represent the browser-based commands for the Java Workshop. The icons from left to right are Back, Forward, Home, Reload, and Stop. The text field at the top of the window enables you to specify a hypertext address to load an HTML page in the Java Workshop. In this sense, it is exactly like an Internet browser. However, you can tell that it is also a professional development environment by looking at the toolbar at the top of the page. In this toolbar, you can see that in this release no title represents what each of those icons means. If you glide your mouse over the icon and look at the bottom of the window however, you will see a brief explanation of what the icon represents.

Figure 6.13 : The Java Workshop advanced beta release main page.

The Portfolio Manager

The first icon on the top left of the screen is a picture of a suitcase that represents the Portfolio Manager. The Java Workshop sorts its Java programs and projects into portfolios. A portfolio is a text file that has a .psf extension. In this text file is a list of references to a specific set of projects. Each project file has the extension .prj and contains high-level information about each project, including a list of source code files and preference information. This file is also in a text-based format. The actual source code files for each project are at the bottom of the pyramid. For a visual organizational chart of the Java Workshop, see Figure 6.14.

Figure 6.14 : Organizational chart for Java portfolios and projects.


NOTE
The Java Workshop is currently the only Java-integrated development environment of all the environments you learned in this chapter that supports the use of portfolios.

Click the briefcase to open the Project Manager. Three new icons appear under the text field. From left to right are Create a New Project, Import an Existing Project, and Remove the Selected Project. In the Java Workshop, whenever you open up a manager (for example, the Portfolio Manager), a set of implementation-based icons related specifically to that manager will be displayed on a subpanel at the top. As an example of how to use the Java Workshop, you will create, test, and run a very simple Java applet. Create a new project called ButtonA by clicking the Create a New Project icon. A tab window will open, giving you several choices to create a new project. In this example, save the project in a special directory called c:\button and create a new applet called ButtonA. In this example, put it on the local drive c:\. When you are finished, it should look something like Figure 6.15. Then click Apply.

Figure 6.15 : Creating a project in the Java Workshop.

You now should have a ButtonA project icon somewhere on the screen. To begin working on the project, simply click its icon. Then click the puzzle icon next to the suitcase on the main panel at the top of the screen to open the Project Manager.

The Edit Project

Moving forward with this example, the next major icon on the top of the screen that you can double-click to open is the Edit Project (also called the Project Manager). In the Project Manager, because you are not really implementing anything, there are no secondary icons to discuss. It is through the Project Manager (see Figure 6.16) that you will be able to set various preferences for each project. In fact, think of the Project Manager as a project preference manager.

Figure 6.16 : The Project Manager.

For the ButtonA project, set the preference for this project to be an applet and place it in the directory called c:\button.

The Source Editor

The next icon, which shows a pencil writing on a notebook, is the Source Editor. Click this icon to open another window to work with your code.

NOTE
You can start a manager more than one way. More precisely, as you will see later in this demonstration, you can activate the Source Editor from the Build Manager and the Debug Manager as well as from the pencil and paper icon bar at the top of the main window.

The next step is to actually write the code for ButtonA (enter the code in Listing 6.1). Figure 6.17 shows the Source Editor with the code for ButtonA filled out.

Figure 6.17 : Java Workshop Source Editor containing the code for ButtonA.


Listing 6.1. The ButtonA.java code.

// Button 1.java



import java.awt.Button;

import java.awt.Label;

import java.awt.Event;



public class ButtonA extends java.applet.Applet {

    Button b;



    public void init() {

        b = new Button("WELCOME");

        add(b);

        show()

    }



    public boolean action(Event e, Object obj) {

        if (((Button)e.target).getLabel() == "WELCOME") {

            b.setLabel("GOOD-BYE");

        } else if (((Button)e.target).getLabel() == "GOOD-BYE") {

            b.setLabel("WELCOME");

        }

        return true;

    }

}


If you look carefully at the code in Listing 6.1, you might have noticed that no semicolon terminates the show() method. It is with this deliberate error that you will see how the Java Workshop responds to this pseudo-real-life situation. This takes you to the next manager.

The Build Manager

The next major icon, designated by a wrench, is the Build Manager.

NOTE
The buttons at the top of the toolbar are arranged from left to right so that as you develop, you use the icons from left to right.

When you open the Build Manager, you will see a new set of toolbar icons displayed in the subpanel on the main window. These icons from left to right are Go to the Previous Error, Go to the Next Error, Initiate a Build, Stop, and Build All Even if They Are Up To Date. For your example, specify the file ButtonA.java. Click the icon Build All Even if They Are Up To Date to recompile the file completely. Figure 6.18 shows the Build Manager compiling the ButtonA example.

Figure 6.18 : The Build Manager.

As you click the Build All Even if They Are Up To Date icon, you can see the integration of the original JDK in the Java Workshop compilation process because a DOS window opens to run the executable javac.exe.

The first line of text on the page actually shows the command line for the compilation of the project:


C:\JAVA\WORKSHOP\JDK\bin\javac -g -d C:\Button -classpath

C:\JAVA\WORKSHOP\JDE\classes;

C:\JAVA\WORKSHOP\JDK\classes;C:\Button C:\Button\ButtonA.java

The lines after that show the deliberate error in the typical javac.exe format, except that a hypertext link is here to edit the file (via the Source Editor) where the error is contained. Click that link to open the Source Editor. If you look at Figure 6.19, you will see that two new icons have appeared. These icons move between error messages. Also notice that the line of code that is offensive to the compiler is highlighted in yellow so that you can immediately see the trouble spots in your code. This is also a nice tool.

Figure 6.19 : Reviewing the applet in the Source Editor from the Build Manager.

Now go ahead and put in the semicolon to terminate the end of that line, save, and close the window. You should be back in the Build Manager. Click Initiate a Build to build only the changes that were made to the original code. At this point you should see Build Successful printed at the bottom the subtoolbar. Your next step in using the Java Workshop in this demonstration is to take a quick look at the Source Browser.

Source Browser

In JDK language, the Source Browser translates to the graphical version for the javadoc.exe tool that was discussed in the JDK. If you remember, javadoc.exe is not very easy to use. The Source Browser has definitely improved on it, however. Here you will be able to see the big picture of the code structure because it shows all the imported as well as inherited classes and the methods used in this class. If you click specific objects, the Source Editor will open and highlight the declaration of the method on which you clicked. The Source Editor also uses a second tab to search the file to get information. This is one of the Java Workshop's strongest points because it is done automatically, giving you the programmer and anyone else who might work on your project a topographical view of what is going on. Figure 6.20 shows how the class ButtonA looks in the Source Browser Tutorial.

Figure 6.20 : ButtonA in the Source Browser.

The Debugger

Debugging can be a long and tedious process. Our applet is so basic that there really is not much to debug, but you will learn some features that the Java Workshop uses. You can manipulate threads, evaluate expressions, and specify break points in your code. The Debugger provides several windows in which you can view messages as well as other objects. Debugging is an integral part of the development process, and the Java Workshop seems to have just about everything that you need for a basic visual debugging environment.

Applet Tester

The next icon, Run Applet or Stand-Alone Program, is a way of testing your applet. Your applet is quite basic; all it will display is a button labeled Welcome that will change to Good-Bye if you click it. But in the process, you have had a chance to work with the Java Workshop. If you did everything correctly, your screen should be similar to Figure 6.21.

Figure 6.21 : ButtonA in the Applet Tester.

Online Help

The final icon (with the question mark) is the Help button for online help. Note that the first advanced beta version evaluated did not have a completed help file. On the surface it looked fairly good, with a table of contents as well as a help topic for every section that we covered.

NOTE
In any integrated development environment, note that a good help file is very important. A good help file should have complete documentation on the built-in classes, coverage of all the major errors when compiling code, a tutorial focused on introducing the user to Java as well as the integrated development environment, and information on how to use the product.

An option that was not included in this pre-release of the Java Workshop is a just-in-time (JIT) compiler. With this relatively new technology, also known as dynamic translation, you can compile very fast executables. It is an important feature that will be a very hot (no pun intended) topic for Java.

Java Workshop Closing Comments

The Java Workshop is one of the most unique development environments in which to work, especially with its Web-centric design that seems to play a major role in the environment. It is also very logically lined out-its icon bar logically reads from left to right, following each step you need to understand the environment. The premise of the Java Workshop is that it is designed to be easy to use and to help focus Java as a development solution for the Internet. This is probably going to be a good integrated development language for users new to Java who want to design Java-powered HTML pages.

Summary

In this chapter, you learned several new products, most of which are already being redesigned in their next version. There are many improvements and new tools coming out for Java almost every month. By the time you read this, Microsoft should have released its Java environment Visual J++ and Symantec should have released Visual Café (a RAD environment for Java).

At this point, the integrated development environments you have learned have their own strengths and weaknesses. The end result is that these tools all will have a place in this new industry. For example, the JDK is definitely the most cost-effective way to develop Java programs. Although the Java Workshop will no doubt focus Java solutions toward the Internet/intranet needs, the advanced Java users will definitely benefit from Symantec Café's power tools. Users who want a more RAD-based ease of use with Java will focus on Borland Latte. For hard-core C/C++ programmers, Borland C++ 5.0 will definitely offer its users better coding integration between Java and C/C++ in one environment. While Java itself is a very new language, Java Integrated Development Environments are in their infancy. Tables 6.1, 6.2, and 6.3 give you a quick reference to compare all of the products learned in this chapter.

Table 6.1. General system requirements (requirements are for the Win95/WinNT platform).

IDEPlatform(s) MSRPHard Disk RAM
JDKWin95/NT, Solaris, MAC FREE6.6MB4MB
CaféWin95/NT $299.9525MB-30MB8MB
LatteWin95/NT, Solaris UNUNUN
Borland 5.0Win95/NT $499.95(*)25-200MB(**)
WorkshopWin95/NT, Solaris $29545MB16MB
NA = Not Available     
UN = Unknown     

(*)Borland C++ 5.0 has two editions: the regular edition and the development suite. The development suite is listed at $499.95. You can also purchase the upgrade for the development suite for $349.95. The regular edition of Borland C++ 5.0 is $349.95 and $249.95 for the upgrade.

(**)The Borland Debugger also has two editions; the size depends on how much you choose to install on your local system and how much you want to remain retrievable from the CD.

Table 6.2. Visual tools.

IDE
Web-Centric
JIT
Visual Debugger
Wizards
Visual Studio
JDK
Yes
No
No
No
No
Café
No
Yes
Yes
Yes
Yes
Latte
No
Yes
Yes
Yes
Yes
Workshop
Yes
No
Yes
No
Yes
Borland 5.0
No
Yes
Yes
Yes
Yes

Table 6.3. Other pertinent comparative information.

IDE
Native Compiler
Integrated Java
Install Shield and C++ Dev Env.
JDK
No
No
No
Café
Yes
No
Yes
Latte
UN
No
UN
Workshop
No
Yes
No
Borland 5.0
No
Yes
Yes
UN = Unknown
 
 
 

Hopefully, this chapter has given you a better understanding of all the available features and where the Java Integrated Development Environments are headed. The next chapter is an introduction to pure Java. It covers all of the structured parts of Java and discusses the object technologies available to the Java language.