Merle Newlan Chapter 4 Installing Java This chapter describes how to install the JDK. Jan 1, 1996 Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Notice: This material is excerpted from Special Edition Using Java, ISBN: 0-7897-0604-0. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Chapter 4 - Other Environments and Compilers

by Jerry Ablan

The Java language and compiler were developed primarily on UNIX-based systems. UNIX systems are not known for their well-developed user interface. Usually, UNIX machines run X-Windows, but you still must use a command-line interface to enter commands. Only the newer UNIX operating environments have the niceties of Microsoft Windows or the Macintosh. Creating command-line interface programs for UNIX is easy, fast, and completely natural to UNIX developers.

Because of these and possibly other factors, the Java Developer's Kit (JDK) currently does not include an integrated development environment, or IDE. Sometime in the future, the JDK may include an IDE, but this niche most likely will be filled by third-party products. As you'll see in this chapter, some interesting entries have surfaced in this arena.

In addition to third-party IDEs, third-party compilers will arrive. As with any language, there are developers who feel that there is a market for a another compiler. Just look at how many C and C++ compilers are currently available.

In this chapter, you'll learn about:

Integrated Development Environments

An integrated development environment, or IDE, is a unique programming setting in which you have all the necessary tools at your fingertips. Generally, a source-code editor is the centerpiece of the program. Arranged around it are: a compiler, a debugger, and other development tools. Better IDEs allow for a certain amount of extensibility. This allows a developer to customize his or her work environment for maximum productivity.

One of the first IDEs for IBM PCs and compatibles was Turbo Pascal from Borland International. This program was an editor and compiler bundled into one neat little package. The program was fast, and it produced tight, fast executables. Borland later enhanced the concept to produce Turbo C and then Turbo C++. Microsoft responded with what it called the Programmer's Workbench. This product was not as slick as the Turbo packages but was very extensible. Some people argue that Turbo C started the compiler wars between Borland International and Microsoft.

In any case, myriad compilers are available today, and a different IDE comes with each one. Each IDE is the producer's vision of the way programmers should work, and that vision is the best (according to the software maker). Unfortunately, all programmers have different methods to their madness and tend toward no commonality. Therefore, many IDEs are available today and have been for quite some time.

The first compilers for Pascal, C, and later C++, had no IDE available initially-only the simple command-line tools. Java is no exception. Currently there is no IDE available from Sun Microsystems for Java development. This will most likely change in the future.

Before the official version 1.0 of Java was released, several IDEs were available for Java. By the end of 1996, a complete IDE probably will be available from each major compiler maker, including Borland, Microsoft, and Symantec. In fact, in the first half of 1996, the following products became available:

Today, several of note-public-domain and commercial- deserve a closer look. Those environments are JavaMaker, Diva for Java, Java WebIDE, Kalimantan, Roaster, Symantec Cafe, and Borland C++.

Visual C++ version 4 from Microsoft is extensible enough to be used as an IDE for Java. This is not really a stand-alone Java IDE and does not warrant mention in this chapter, but it can be configured to be useful. This information is available at the following URL:

http://www.ivas-as.attistel.co.uk/java/vc-java.htm

So without further ado, let's look at some IDEs.

JavaMaker

JavaMaker, written by Heechang Choi in 1995, is a simple public-domain IDE for the Windows 95 and Windows NT platforms. JavaMaker provides a simple editor, compiler, and applet viewer launcher. figure 4.1 shows the JavaMaker main window.

fig. 4.1
The JavaMaker main window is a standard Windows application with support for multiple source code windows to be opened at once.

At startup, JavaMaker provides a blank document window for creating a new class. You can close that window and open an existing class. When a class is loaded or a new class is saved, JavaMaker places the name of the class at the top of the main window and the document window. figure 4.2 shows a loaded class.

fig. 4.2
The JavaMaker system is shown with the TumbleItem class loaded.

After you have loaded a class, or typed a new one into the entry window, your next step is compilation. JavaMaker provides a Tools menu that contains several options, the first of which is Compile. This option starts the Java compiler, javac, and places the output of the compiler in a new window called Output, as shown in figure 4.3.

fig. 4.3
The compilation output is shown in a separate window.

If errors occur, the output window displays them, along with the numbers of the lines on which they occurred. One nice feature of JavaMaker is the fact that when you double-click the error message, the cursor moves to the offending line in your source-code window. If your class was compiled properly, you can run the AppletViewer tool to view your applet. figure 4.4 shows the AppletViewer command in the Tools menu.

fig. 4.4
The AppletViewer is launched from the Tools menu.

AppletViewer runs in its own window and runs the class that was currently active in JavaMaker. figure 4.5 shows AppletViewer running the TumbleItem class that comes with the JDK.

fig. 4.5
The AppletViewer runs the Java applet that you are currently working on in JavaMaker.

JavaMaker is a simple IDE that offers only a bundled editor, compiler, and launcher tool. JavaMaker is a good improvement over the command-line tools and should speed your development effort.

Diva for Java

Diva for Java, formerly known as Javaside, is an IDE from Quintessential Objects, Inc. The IDE is available for the Windows 95 and Window NT platforms, and requires the JDK. Diva more closely models the Visual C++ version 4.0 development environment than JavaMaker does. Diva even associates itself with .java files, so that when such a file is opened from the Windows Explorer or via a shortcut, the Diva application starts automatically. At the time of this writing, Diva for Java was only available in an alpha state. The alpha and beta versions are available free from the URL above. However, the 1.0 release of Diva for Java will be a commercial product.

Diva for Java utilizes a project system. This system manages the source code files that are part of your applet or application. Projects can include multiple source code files. When you create a new project with Diva, you insert new files into the project. Usually with Java, each file is a separate class, therefore a complex project will have many source-code files. The management of these files can get out of hand quickly. Having the IDE manage the project is a very nice feature.

figure 4.6 shows the Diva startup-tips screen.

fig. 4.6
At startup, Diva for Java shows the tip of the day in a "What's Cool" window.

Along the left side of the screen is the project view, which details the files that make up the current project. You can create new projects that include Java source code, HTML, and special Diva Design documents .jad files). These design documents are created with the Diva Designer. There is more information about the Diva Designer coming right up. figure 4.7 shows the project view panel.

fig. 4.7
The Diva for Java project view panel shows the files used in the current project.

At the bottom of the screen is the compiler output window, which displays all output from the compiler. You can double-click errors to move directly to the correct place in the source code. The current file appears in a new window above the output window, allowing you to edit and manipulate the file.

When you insert a new file into the project, the software asks you what type of file you want to add: Java, HTML, or Diva Design document. figure 4.8 shows the selections that are available.

fig. 4.8
New files can be inserted into the project with new file addition window.

If you select Diva Design Document, the Diva Designer window opens (see fig. 4.9).

fig. 4.9
A blank slate for laying out your designs in the Diva Designer.

The Diva Designer allows you to create Diva Design documents. The interface is similar to other window prototyping tools. Objects are available on a palette. These objects can then be selected and placed on your window. Once placed, the objects can be given names. These names are used when Diva for Java generates source code for your applet. After you've laid out the objects you want on your program's window, you can have Diva generate a class file around your design.

Before Diva can generate your source-code, you must select the type of application template that Diva will use. The selections include a basic application with a frame or an applet. figure 4.10 shows the selection window. This list can also be extended. Instructions for customization are included in the Diva distribution.

fig. 4.10
The application selection window

The coolest thing about Diva is the source-code-window navigation panel, which is displayed next to the source code at all times. This window represents the code in a treelike graphic. At the base, or root, of the tree is the Java source file itself. At the next level up are the imported libraries; the top level shows the class or classes defined in the file. All variables, methods, and extensions appear below the class. Simply click a variable or method, and you are instantly taken there in the source code window. This feature is very nice. figure 4.11 shows a source code window with the class navigation panel.

fig. 4.11
The class navigation panel allows you to move about your class by method.

Even though this is the pre-release version of Diva, it is still a useful program. The release 1.0 version of Diva should be a good entry into the IDE arena.

Java WebIDE

Java WebIDE, written by Chami Wickremasinghe, is not just a public Web-based compiler; it is a nearly complete IDE written entirely with HTML and Java/JavaScript. You access it only via the World Wide Web. There is nothing to download and it is completely free. All the compilation is done at the Web site, not locally. figure 4.12 shows the Java WebIDE in action.

fig. 4.12
The Java WebIDE is an IDE implemented completely with HTML.

Included in this unique IDE are an editor, compiler and the entire JDK documentation online. You can enter your code in the editor and then click the Compile button. The output then is available for downloading via the compilation screen (see fig. 4.13).

fig. 4.13
Java WebIDE shows this screen when compilation is successful.

All in all, using the Java WebIDE is a very unique experience. The faster your Internet link is, the compilation results will return to you more quickly. Also, if you are looking for an integrated debugger, Java WebIDE is not your IDE. If your development needs are small, the Java WebIDE may be just your ticket.

Kalimantan

Kalimantan (formerly known as Espresso) is a set of public-domain tools for creating and debugging Java applets and applications. Although Kalimantan is not a full-blown IDE, it deserves mention in this chapter because it includes some non-command-line utilities. These utilities are an Inspector and a Debugger. The Inspector is a tool that allows the programmer to fully explore the contents of an object. The Debugger allows the programmer to set breakpoints in a Java application or applet and then to use the Inspector to inspect the source code and variables. All of the Kalimantan tools are written in Java, so they are portable to any operating system that support Java.

fig. 4.14
The Inspector is inspecting the current running Java system.

These tools are very much like the Smalltalk programming environment; the only portion that's missing is the class browser. To overcome this limitation, the Kalimantan tool set is bundled with another tool set called dejava (Development Environment for Java), which includes a class and method browser, among other features. These tools run in any platform that supports Java. However, they have only been tested in Windows 95 and Sun Solaris.

fig. 4.15
The Debugger window shows the source code of the currently running applet.

Roaster

fig. 4.21.
Roaster provides a complete development environment for the Macintosh.

Roaster, from Natural Intelligence, Inc., is the first commercial Java IDE available for the Macintosh. The features of Roaster include an editor, a compiler, a debugger, and a class disassembler.

Because this product is still in its infancy, not much information about it is available. According to the release notes, Roaster works only with PowerPC Macintoshes, not with 680X0-microprocessor-based Macs. In addition, the product still supports only the beta JDK, even though the 1.0 release of JDK is out. The compiler is not yet working properly, so the manufacturer recommends using the compiler that comes with the JDK. Java's Abstract Windows Toolkit is not fully supported, and no source-level debugging is available, a fact that makes the debugger somewhat useless.

Symantec Cafe

Symantec Cafe is a commercial Java IDE built on Symantec's C/C++ IDE product. First available with the version 7.2, the upgrade is downloadable from Symantec's FTP site as an upgrade. The upgrade allows for the development of Java applets. Symantec CafΘ is now available as a complete, stand-alone, Java development environment. figure 4.17 shows the CafΘ system.

fig. 4.17
The Symantec CafΘ product has multiple windows for which to view the current project.

Cafe provides a graphical Java class hierarchy diagram that is created on the fly by the IDE. This diagram helps the developer understand the layout of the Java class library and where the classes created by the developer belong. Cafe also provides a class editor, which allows the developer to work on the classes in his or her project. Editing by a class view is much easier to deal with than individual source code files are.

Cafe also includes two wizard-like features called AppExpress and ProjectExpress. These features generate a complete, fully functional Java applet skeleton that can be enhanced and revised through the Cafe system.

Borland C++ Version 5.0

It would be sad if the granddaddy of all IDEs didn't throw its hat into the ring. Borland International recently announced that version 5.0 of its C++ development environment, will include complete Java support. This support includes integration with the JDK, a programmer's editor, and a graphical source-level debugger. The debugger itself is written in Java and is the first of its kind. This product became available in March of 1996. figure 4.18 shows the Borland Debugger.

fig. 4.18
The Borland Debugger for Java is written entirely in Java.

At the time when this chapter was written, not much information about the Borland C++/Java product was available. The new IDE is likely to be built on the version 4.5 product, which includes features such as a class editor/browser, an extendible programmer's editor, and AppExpert.

AppExpert, the shining star of the Borland development tool, is very similar to Symantec's AppExpress and Microsoft's AppWizard. AppExpert allows a developer to build an application from the ground up; it then creates all the support tools and scripts needed to compile and run the target application.

Borland has promised Java support in AppExpert. Symantec already has support, and Microsoft probably will, too, at some time.

Other Java Compilers

Because Java source code is compiled in a byte code that is interpreted instead of executed, just about anyone who has the desire and the know-how can create a Java compiler. As the language evolves and matures, more and more compilers will arise. The speed of these compilers will be the defining factor of their success.

At the time when this chapter was written, two third-party Java compilers were available. The first compiler is part of the Roaster package from Natural Intelligence, which is discussed earlier in this chapter. The second compiler is EspressoGrinder, which is discussed later in this chapter.

Public compilers also are available. A public compiler is a Web-based interface to Java's javac program. The purpose of public compilation is to provide compilation access to people who have platforms for which the JDK is not available. The third party compilers and the public compilers are discussed in more detail in the following sections.

EspressoGrinder

EspressoGrinder is the first replacement compiler for Java. The compiler's most notable features are its size and speed. EspressoGrinder is approximately half the size of the Java compiler javac and twice as fast (in compilation speed).

Compilation speed is the time that it takes the program to compile the Java program, not the speed at which the program executes.

EspressoGrinder is available for UNIX and Windows 95 systems. This product requires that the JDK version 1.0 be installed.

The compiler is part of a larger ongoing project by the EspressoGrinder team to make better tools and languages available to more computer professionals. One part of this project involves providing a native-code generator for Java. The native-code, in conjunction with an interpreter, would allow for increased performance and speed unseen today. For more information about their project, check out:

http://www.icsi.berkeley.edu/~phlipp/espresso/Project/

Black Star Public Java Compiler

The JDK does not support some UNIX and microcomputer platforms. Also, some people may not be able to install and run the JDK. This can be because of lack of resources or sufficient permission on the target computer. What is someone to do who cannot run the Java compiler but wants to develop Java applications? Enter the public compiler.

Because the Java compiler produces a byte code that is interpreted instead of executed, the compiler does not require execution on the target machine. The compiler can run anywhere really, all that is needed is the compiled .class file. This feature opened the door for the Black Star public compiler.

The compiler accepts as input an upload from a client; it then passes this upload to the Java compiler (javac) for compilation. figure 4.19 shows the compiler main page.

fig. 4.19
The Black Star public compiler Web site has complete instructions for its use.

One of the newer browser features is the capability to upload files to a Web server. The Black Star site takes advantage of this feature. The Web site allows you to upload your Java source code directly to the server. If your browser is not capable of uploading a file, you are also able to hand-enter your source code. This method is called the text-entry method of compilation. The text-entry method is available on another Web page at the Black Star site. Again, complete instructions are given.

After compilation, if no errors occur, the public compiler produces a page that has links to your compiled class files. These files need to be downloaded to your system via this page. No other access is available. figure 4.20 shows the Compiler output page.

fig. 4.20
The output of the compiler is displayed on a new Web page as well as links to your compiled class.

The Java Public Compiler

This site is another public interface to Java's compiler, javac. This interface is a little bit nicer than the Black Star Web site. The site allows for up to five source files and other options. figure 4.21 shows the input system.

fig. 4.21
The Java Compiler Service site has a much nicer interface than the Black Star site.

After you enter the names of your source code files, you can select the options that you want the Java compiler to use. This feature allows you to compile in verbose mode or in debug mode. figure 4.22 shows the available compilation options.

fig. 4.22
The Compiler Service's Java allows you to select any of the compilation options available in the javac program.

When the compiler finishes compiling your source code, your browser displays the Compilation Results page (see fig. 4.23). Simply click the class file that you want to download, and the file is transferred to your machine. Compilation could not be easier.

fig. 4.23
The compilation results.

QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation