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.
by Luke Cassady-Dorion
There are multiple Java development environments which you could choose to work in. This chapter teaches how to use Natural Intelligence's Roaster. Once you finish this cheater you will fully understand all the features which Roaster brings to the Macintosh. And once you become an accomplished Java programmer, this chapter should serve as a reference to you as you work with Roaster.
This chapter will teach you how to:
Natural Intelligence filled a void in the Mac Programming community when they released their Java Development Environment in January of 1996. Previous to this Mac programmers wishing to get a jump on learning Java were unable to without jumping to other platforms. Roaster allows Mac programmers to create Java applets for use on World Wide Web pages, and also allows for the creation of minimal use applications (development of applications with Roaster is covered later in the chapter).
Roaster is Natural Intelligence's Integrated Development Environment (IDE) for the Macintosh. The program is a powerful tool for developing Java Applets (and partial applications) on the Macintosh. These Applets can be used in your Web creations to bring new energy to static environments.
Buzz words aside, Roaster enables you to create some very cool stuff.
Java, unlike HTML, does have a steep learning curve, especially for new
programmers. Roaster will do nothing for you if you cannot program in Java.
The current version of Roaster is version Developer Release 1.1.
As is the case in general in the computer industry, information is current only for about 10 minutes. This text is based on Developer Release 1.1 of Roaster, and press releases current at this time of writing. A new version of Roaster is expected quite soon, and Roaster Pro is expected out in May 1996.
This version, however, is not the one which was mastered on the CD. The CD ships with version DR1.0, and the update is available from Natural Intelligence's Web site at http://www.natural.com/pages/products/roaster/updatenoterdr1.html, or by contacting them at 617-876-4876. To install the CD, drag its contents to your hard drive, and then move the Roaster VM extension from the "For Extensions folder" folder to the extensions folder on your hard drive. You will notice a variety of free software which Natural Intelligence has bundled in on the CD. None of this is required to run the program, but is quite useful; this chapter, in fact, was written using BBEdit. Restart your computer, and Roaster is ready to go. If you are having troubles with running Roaster make sure that you copied all of the files shown in figure 5.1
Fig. 5. Once installed on your computer, Roaster will present itself with the following window.
After the programming geeks develop an application, the information systems geeks take over and shape the product's interface into on which users feel comfortable interfacing with. Natural Intelligence, in developing the product, was well aware of the fact that an interface can make or break a product. All commands are easy to locate, and are not masked with confusing names.
Before you begin developing your first applet, sit down and familiarize yourself with the environment. You will be happy with the control you have over the application.
Unlike the Java Developers Kit for the Mac, Roaster is a complete Integrated Development Environment (IDE); this involves a combination of a powerful text editor, interpreter, and compiler all in one. Roaster also bundles a debugger with their environment.
The IDE that Natural Intelligence has created for Roaster integrates a version of their powerful QuickCode Pro editor with a suite of Java development tools. This includes the Sun javac compiler, and also their own compiler. The combination of these two compilers provides for increased user flexibility. The Java developer can opt to choose from Sun's compiler which is not as fast as the Natural Intelligence's own compiler, but tends to generate fewer compile time errors that the Natural Intelligence compiler. Or the Natural Intelligence compiler which, while faster, is still deep in development. To switch between the two compilers choose from the Edit menu, Preferences, and then click on the Compiler icon. If you are confused look at the screen shot in figure 5.2 this is what you should see on your screen.
Roaster still classifies their compiler as "icky" and recommends that for the time being that you use Sun's compiler.
Fig. 5.2 Natural Intelligence combines two compilers with their development environment. The NI compiler promises to go above and beyond Sun's compiler in both speed, and class support in the near future.
To manage an increasingly large amount of project files, Roaster incorporates a hierarchical project manager system. This system displays all project files in a window, which supports a drag-and-drop interface. This enables you to add files to the project simply by dragging them to the project window. You will find this especially helpful as your projects grow in size, and begin containing many project files.
The Roaster interface puts their development tools right at your fingertips. Their versatile code editor supports multiple clipboards; you will find this extremely helpful when managing code snippets. All Roaster menu commands have associated keyboard shortcuts, thus cutting down on the annoying keyboard to mouse exchange that often bothers programmers.
With Roaster, Natural Intelligence includes a special version of QuickCode Pro, their popular code editor.
3 Note how the code editor deals with your code. Special words are colored, and new sections are automatically indented.
The editor supports syntax coloring, and brace flashing to instantly notify a user if a brace has been accidental omitted. Take a look at figure 5.3, this window shows an applet that you will be developing later on in the chapter. Note how the editor deals with the code, pretty cool huh? The colors and text style used for special words are configurable by choosing Edit, Preferences, Text Styles. At this time it's not possible to add words to the database of special words; it is unclear if this will be possible in future releases. It is possible from this section to turn off syntax coloring, and also to set the display font.
There is no real reason to turn off syntax coloring; if the preset colors bother you, feel free to adjust them. Once you become accustomed to the colors, you will catch code errors much faster.
One of the code editor's most useful capabilities is its customizable tool bar. The tool bar includes a method browser, two powerful find utilities, book marking utilities, and a quick commenting tool. The tool bar also allows for complete control over both named and unnamed clipboards, code balancing, both redefined and user-defined macros, text shifting, and incorporates support for multi-platform file formats. Control over the tool bar was designed with human-computer interface guidelines constantly in mind.
The method browser is a pop-up menu which when held down displays a running total of all methods in the current window. The methods are displayed using the convention class_name.method_name; again, as your projects begin to grow in size this tool will prove invaluable. Figure 5.4 shows how the method browser displays the available methods, to instantly go to a specific method, simply choose it from the pop-up menu.
Fig. 5.4 The method browser provides a hierarchical list of all methods which you have developed so far in the current file.
If you are wondering what methods are, don't worry, we'll explain all of this later on in the book.
The two included find utilities are a "Quick Find" tool for locating repeating occurrences of a string, and a "Zip Find" tool for more advanced searching capabilities. To use the Quick Find tool simply highlight a string in the development window, and then click the "Quick Find" icon. This will search from the current selection to the bottom of the file. To search from the current selection up to the top of the file option-click the "Quick Find" icon.
The Zip Find utility allows for some more advanced searching techniques. To use this tool choose "Configure Zip Find..." from the menu accessible under its icon in the tool bar, and enter a search string when prompted. In addition to entering a search string, the Zip Find tool allows for a variety of search options to be configured from this menu. Clicking the OK button causes the Zip Find menu to update itself, containing a listing, by line number, of all occurrences of your string. Figure 5.5 shows how the code editor brings you instantly to the location of a string occurrence.
Fig. 5.5 Note how selecting a found word from the menu instantly highlights its location in the text.
The search criteria feature is also added to the pull-down menu to accommodate repeating this task. To go to an occurrence of the string simply select it from the pull-down menu. To perform search and replace commands, choose Search, Find; this menu allows more complex searching capabilities.
To accommodate quick movement to commonly referenced parts of your code, you can add jump points with the Bookmark tool. Just select the location in your code which needs to be book marked, and click in the bookmark icon.
Try this out; the paper clip, which appears over the icon, indicates a bookmark is has been added. Option-clicking the bookmark icon will void its link.
To reference that location in the future simply click the icon. The number of your project's bookmarks is limited only by your system's memory. See the end of this section for more information on customizing the tool bar.
Java supports multiple styles of commenting: one for individual lines, one for blocks of text, and another which is used to develop documentation. You can control these first two types of commenting via the tool bar. If you want to comment out a single line of text, place the cursor at the start of the text and click the comment icon. Option-clicking the icon while you have a block of text highlighted will comment out that whole block.
Two tool bar utilities which you will no doubt use over and over are the named and unnamed clipboards. These utilities allow for intelligent managing of multiple code snippets. Figure 5.6 shows the clipboard utility as it manages multiple code snippets.
Fig. 5.6 This figureshows the addition of new text to a clipboard. Note all of the other tools available to the clipboard utility.
Named clipboards are used more when dealing with commonly used code. To load something to a named clipboard, select the text, and from the named-clipboard pull down menu choose New under Cut or Copy; the editor will then prompt you for a name for this code. This code can now be referenced by name from the named-clipboard pull-down menu. These snippets are in range for the entire project, thus you can copy and paste between project windows with increased ease.
If you attempt to add a new entry to a named clipboard, and it does not seem to load, make sure that the window has been saved to disk. Currently it is not possible to add to the named clipboards on a new, unsaved window.
The unnamed clipboards are used more for code which will be accessed only a few times. To load code into these clipboards, select the code and use the standard clipboard management tools-just like you did with the named clipboards-under the unnamed clipboard pull-down menu. When a unnamed clipboard is storing data its icon changes to a clipboard with a piece of paper attached. These clipboards also have a range of the entire project. In addition to the standard suite of clipboard commands, there is added support for some advanced commands which you will find helpful. Take a second to familiarize yourself with these menu commands; again, you will find them very helpful.
Of course, you can use the traditional clipboard commands from the Edit menu. These are useful for inter-application text manipulation.
Locating a missing parenthesis, brace, or bracket can be a source of programming headache, especially as the wee hours of the morning approach, when your eyes blur everything together. The code balancing utility will test for matching parenthesis, braces, and brackets. As methods become increasingly developed this utility becomes very helpful. To take advantage of the utility place the cursor at an open section marker, and, when clicked, the utility highlights the text as far as the corresponding close section marker.
As the number of Roaster projects worked on increases, the amount of code which is repeated also increases. This can range from standard comment headers to developed event loops. To accommodate this, the tool bar can take advantage of macros.
Macros are definitely a very cool utility. I take advantage of them by building macros around all of my commonly used methods. I then never have to retype them! I also program basic method frameworks to macros, and then only have to modify them to create new methods. Remember they stay in range for any project which you develop, so unless you delete them they are around forever.
To define a macro select the text in your code which will be reproduced, and choose Macro, New Macro, and then enter the text of the macro into the window which appears. You are presented with a dialog box asking for a macro name and identifier. The name is displayed in the macro menu, and the identifier is used to reference the macro in other macros, giving you the ability to create nested macros. To use a macro in your code, either choose the macro by name from the macro menu, or assign a keyboard shortcut to it. You can assign a keyboard macro by selecting Configure Hot Keys from the NI menu in the tool bar. Figure 5.7 shows how to accomplish this.
Fig. 5.7 Adding keyboard shortcuts to commonly used functions can help to increase productivity. I use them to automatically place in over-used parts of code.
Select this menu item, click the macro name from the menu which appears, and then press the hot key combination you want to associate with the macro. In addition to user-definable macros, there is also a set of built-in macros which include: Date, Time, User name, and Window name. You can modify the macros' names by choosing Macro, Macro Options.
When code demands the addition of a new loop at the center of the method, a programmer who uses proper formatting techniques will indent their code one tab stop farther. Moving code a tab stop to the right or left can be shortcut by selecting the code, and clicking either the Shift Left or Shift Right icons.
Java's cross-platform object-oriented nature leads to situations where code you wrote on one platform might be compiled on a different platform. This can cause problems because Macs, UNIX systems, and Windows-based systems all treat text files in a slightly different manner. To accommodate this, Roaster has added the File Format utility to the tool bar. This utility brings up a menu which enables you to select your code's format.
To recognize each icon's command, place the mouse over the icon and a small help box appears to give the utility's name. This is true for all tool bar utilities. You also can display the utility's name in the tool bar if you would prefer. Note how the first method is being performed in figure 5.8.
Fig. 5.8 Holding your mouse over any one icon for a second or so will display its function.
To configure the tool bar, choose Configure Tool bar from the pull-down menu which is displayed from the NI icon on the top left side of the tool bar. The configuration window displays a scrolling list of all tool bar utilities, and a picture of the current tool bar. To add a new icon to the tool bar, simply drag the utility name to the tool bar. The utility is displayed as either text, icon, or both (depending on user selection) in the tool bar. The individual entries can be dragged into any order which the programmer finds useful. To remove an icon from the tool bar, simply drag its entry to the trash-can icon which is displayed conveniently in the tool bar configuration window. Figure 5.9 shows all of this in action.
Fig. 5.9
Configuring the tool bar is as easy as dragging
and dropping the desired utility onto the tool bar-if programming were
only this easy.
The tool bar allows for multiple instances of a single utility; this
is helpful, especially when defining a series of clipboards to organize
your code. A scrolling system is established to accommodate more entries
than will fit in the tool bar.
For a description of each tool bar utility, click its entry in the configuration window.
The Audio CD Utility enables you to control your audio CDs while engaging in long, Java-enhanced Java coding sessions. It is always part of my tool bar, but then I hooked up my stereo to the audio out jacks on my computer!
The Roaster IDE uses a Project Manager Window to organize the files which your project utilizes. To start a new project choose Project, New Project. The current release of Roaster requires that all projects use the project_name._ (option-p) naming convention. Also, if you are developing an applet with your project Roaster requires that the class which extends java.applet.Applet have the same name with which it is saved.
The Project Manager supports full drag-and-drop capabilities. To add a file to your project, simply drag it from the finder to the project manager window. The project manager allows the grouping of your code under separate headings. Next to the code's name in the Project Manager Window is a pop-up menu which displays, using a hierarchical menu system, the name of all classes and their associated methods. This is shown in figure 5.10.
Fig. 5.10 Choosing a method in one of your project files is as easy as selecting its name from the pop up menu
It is important to step through a sample project to show how one would build an Applet or Application with Roaster.
To launch Roaster double-click its icon in the finder. This brings you into the Roaster IDE. The IDE includes all tools necessary for developing the project itself.
To actually view the applet, it is necessary to use the Applet Runner.
Choose Project, New Project when prompted, create a new folder for your project, and then enter a name for your project. For your sample project, use the name hello._. Creating a new project brings up the Project Manager window (for more information about the Project Manager see the previous section). A new project contains no files; as you build your project you will add to this window. All applets in Roaster require the addition of the "AppletViewer.class" to add this project to your project window choose Add Files... from the project window. Navigate to the AppletViewer.class file which is nested deeply in the various Roaster sub folders. To find the file open the Roaster folder, and then open the Classes folder, inside this dig into the Mac folder, and finally you will find the file nested inside the Applet folder. Highlight the file, click Add File, and then click Done.
This whole process can be simplified by taking advantage of the drag-and-drop features of the Project Manager; simply drag the file onto the Project Manager window.
Create a new file by choosing File, New. Into this new window enter the following code:
import java.awt.Color; import java.awt.Graphics; import java.awt.Font; public class helloAuthor extends java.applet.Applet { String greeting = "Hello Luke"; Font myFont = new Font("Helvetica", Font.PLAIN, 24); public void paint(Graphics g) { g.setFont(myFont); g.setColor(Color.magenta); g.drawString(this.greeting, 10, 50); } }
As you enter the text notice how the text changes color. As you become familiar with the Roaster environment you will begin to know which words change color, and which stay black. This is extremely helpful in finding typos as you generate code.
Now that you have the above text entered, choose File, Save. When prompted, name the file helloAuthor.java and save it in the same folder as your project. Note that at this time Roaster requires you to name your source file with the same name as your class, and requires the source files to be in the same folder as the project. Choose Project, Add Window. This adds the file to your Project Manager. Of course you could drag the source file into the Project Manager yourself. As the number of files which your project manager contains begins to grow it you will want to group and order them in the Project Manager.
Now that you have a complete project choose Project, Compile. If you have no errors, Roaster adds a file to your project folder with the .class naming convention. This file is your byte-code, and can be distributed for viewing on many Web pages. Although unless you are terrible satisfied with my chapter, and wish to say "Hello" to me all over the Internet I am sure that you will not want to place this applet on your Web pages.
To view your applet one more thing is still necessary: the HTML code which defines the layout of your page. Create a new file by choosing File, New, and entering the following text into it:
<html> <head><title>Hello Author</title></head> <body> <applet code="helloAuthor.java" width=300 height=60> </applet> </body> </html>
The preceding HTML is obviously quite minimalistic. This is because the Applet Runner will only interpret the <applet> tags, and is not a complete Web browser. There obviously is no need to place any other miscellaneous HTML around the page. The file needs to be saved in the same folder as your project, and must be named "example1.html." This file name requirement was hard-coded by Sun, and Natural Intelligence plans to allow for any .html name in the future. Now you are ready to check out the applet. Figure 5.11 shows what the final output for the applet is.
Fig. 5.11 Once you get the applet up and running, you should see output similar to what is pictured above.
Choose Run from the project menu, or drag the html file on top of the Applet Runner, to launch that application. Assuming that everything has been entered correctly, there should be a magenta colored greeting directed towards me in a gray colored box.
As previously stated, the DR1.1 release of Roaster will not compile stand-alone application into native code.
Watch for Roaster Pro in May; this will enable you to compile your application into code native to many platforms. Think of how easy it will be to develop cross-platform products in the future!
It is, however, quite possible to view Java applications with the Applet Runner. Now close your current project, and create a new project (remember how to do this?). This time don't add the AppletViewer.class class to your project. This file is only for applet projects. Create a new window, and enter the following text:
class heyLuke { public static void main (String args[]) { System.out.println("Another exciting creation"); } }
Save the file as heyLuke.java and add it to your project window. Before you can run the application you need to tell Roaster that your file is an application, and that it should be the startup file.
In the case of applets, the startup file is the AppletViewer.class; Roaster automatically specifies this when you add the file.
To indicate that heyLuke.java is your startup file, highlight it in the project window, and choose Set Startup File from the project window. Notice the arrow which now appears next to the file name? More kudos to Natural Intelligence's adherence to human-computer interface guidelines. Now that the file has been ear marked as your startup file you are ready to run the application. Choose Run from the project window, and what do you know? More fun from the Java department. The output for this application is shown in figure 5.12. Try playing around with the application a little. Can you make it output the text in color? If not don't worry, by the time that you finish this book you will be able to do anything that you want with Java.
Fig. 5.12 The output for our complex application. Hey what will these brilliant programmers think of next?
The decision on whether to develop an applet over an application depends on the scope of your project. Often a project can seem to exist in both the applet, application categories, and in fact sometimes two versions of a product will be developed. Applications due to the fact that they do not require a Web browser interface allow for greater flexibility. The security issues which an applet possesses do not exist with applet development. As you become increasingly familiar with the language it will become much easier to decide which route your projects need to take.
While Roaster is an advanced Java development environment, it does still
have some room for growth. Note that at the time of this writing neither
Roaster Pro nor DR2.0 of the current environment have been released. These
programs promise to bring many enhancements to the Roaster environment.
Currently Roaster supports only one release specification of the JDK. At the time of this writing, Sun has released the JDK in its final 1.0 state. Natural Intelligence has been doing a great job keeping up with advancements in this ever-changing market, and plans to support a more advanced version of the JDK.
While Roaster supports only one release of the JDK, it does not fully implement its current state. Some of these reasons are due to restrictions placed on Roaster by the Mac OS, and other reasons stem from Natural Intelligence's rush to get this product into the hands of developers. These restrictions are far from limiting; one can develop a complex project with Roaster.
While Roaster does not support some aspects of the current specification, it will still generate proper byte-code; thus browsers on other platforms will be able to fully use the applet.
The restrictions the Mac OS places on Roaster are possible to override, but doing so is not a desirable thing for Mac programmers to do. Doing this means overriding many toolbox calls, and can make the program highly incompatible with future releases of the system software (including 7.5.3). If you have never programmed for the Mac before, the toolbox might be something new to you. The toolbox contains a series of functions which deal with the Mac's graphical interface, memory management schemes, and other Mac specific functions. Java supplies its own methods to deal with these situations, including the Abstract Window Toolkit (AWT), thus a Java programmer does not need to bother with toolbox calls. All translation to the Mac interface is taken care of by the geniuses who write the Applet Runner software.
Currently the Mac OS requires applications to have a standard look and feel, Roaster's Applet Runner has done a great job of making Java projects conform to that look and feel. For example, the AWT lets users create text areas of varying background colors; on a Mac text areas are always white, thus any calls to change a text area's background color are ignored. Also it is obviously a rare occasion that, on a Mac, pop-up menus will appear in a font other the preset system font. Roaster's applet viewer will conform to this by not interpreting any calls to menu font change. Java also allows for a Windows feel by supporting window iconization. This will not occur with Roaster's applet viewer. Any programmer wishing to develop for the Mac, even in Java, should familiarize himself with the Mac toolbox. Apple's Inside the Macintosh series is a great resource for tool bar programming.
In addition to a slightly "Mac-ified" version of Java support, Roaster has not fully implemented the JDK is its current state. This poses little problem, however, and it must be remembered that the release of Roaster current as of this writing is a developer's release, and that it is not expected to be in its final polished form. The most obvious omissions to the Roaster environment are the lack of net, and audio support. Again, look for .net support in DR2.0. The Applet Runner which comes with the Mac JDK from Sun does have net support, and thus it is possible to view applets which take advantage of this class with their Sun Applet Runner. Also at this point jpegs are unsupported by Roaster, all images which a developer may want to display must be in GIF format. Finally, the File Dialog is also currently unsupported.
Currently much of the hype surrounding Java development is related to applet development. However, Java's application building qualities are perhaps even more powerful. It is possible to develop applications which, for example, dynamically update themselves over their network. Thus a company never needs to worry that a staff member might not be using the latest version of a software product. It is estimated that companies spend millions of dollars just in physically making sure that all products are kept up to date. As a Java programmer, your applications-if they support this capability-will have a much higher selling value.
Roaster currently supports a minimal version of application development. Roaster Pro, which may be out at the time that this is published will allow for complete stand-alone application development. This includes pure byte-code development, and also native code development for multiple platforms.
To write an application with Roaster, develop your source code in the traditional manner, and then in the project window highlight the file which contains your main() method, and choose Set Startup File from the project menu. Then when you run the application, the Applet Viewer will be able to properly interpret your code. Note when doing this to make sure that you do not include the AppletViewer.class or the Applet Viewer will get confused. The AppletViewer.class is used solely for applet development.
Of all the hours that you will spend working on code, most of your time will be spent on debugging. This might range from finding a missing semi-colon (my favorite), to dealing with incorrect variable handling. Finding errors in Java based projects is, for the most part, much easier than in projects developed in languages such as C++. This is due in part to Java's automatic garbage collection, and decreased dependence on pointers. There are plenty of situations where you will not be able to trouble-shoot your code merely by examining it, and will need to turn to a debugging utility.
In the development of Roaster, Natural Intelligence opted not to include Sun's dbx debugging library, and decided to develop its own graphical debugging environment. At present the debugger is not in any way a complete product, and is probably the most underdeveloped component of the IDE. This however does not stop you from using the debugger to solve problems with a project, and Natural Intelligence promises to deliver a full force debugging tool in the coming months.
To work with the debugger a .class file must be developed first. This means that unless you are able to work out all syntax errors, and get the code to compile correctly you will not be able to use the debugging tool.
Natural Intelligence's compiler is not too intelligent when it comes to describing errors in your source, thus fixing these errors can be more time consuming than is really necessary.
To run the debugger, open the project on which you will be working. If you have not already compiled the code, now is a prime time to this; as stated earlier, the .class file is required for the debugger to run. Once the project is open, choose Project, Enable Debugging.
Note the check which appears next to the debugger menu option; this indicates that the debugger will take over operation once the project is run.
You will notice that your code has been shifted to the right about 1cm, and there is now a thin gray line running down the page. You can click to the left of the line to set a debugging breakpoint. Figure 5.13 shows a class file being debugged.
Fig. 5.13 The debugger at work. Natural Intelligence debugger will let you step though your class file, tracing the path of a variable.
A breakpoint is a point in your class file where the debugger will automatically pause execution.
To set the breakpoints for the .class file just open up this file, and insert them in the fashion described above. If you are totally unsure where to set your breakpoints there are a suite of tools which will help you locate the problem. These tools are displayed on the tool bar which is displayed when the debugger is fired up. Well, let's fire up the debugger, and look at a program!
In this release of the debugger it, breakpoints placed in the source code will be ignored. This is partially due to the fact that the debugger does not support source level debugging. This is currently one of the biggest weaknesses with the debugger, Natural Intelligence plans to release a debugger with source level debugging capabilities in the future.
Fig. 5.14 The Project window with debugging enabled. Note that once debugging is enabled, it stays enabled until you turn it off.
Choose Project, Enable Debugger, Run (see figure 5.14). The debugger now displays your .class file with a small green arrow next to the first instruction in the code. The debugger only executes a line of code when you give it permission. This is quite helpful as you are able to step through the program and trace exactly what happens line by line. If errors are deeply nested within the program, this can be a rather tedious process-you might want to have a hot pot of Java sitting at your side! The debug tool bar displays a series of icons which allow you to control the execution of the program. One other window that you might want to bring up at this point is Windows, Current Object Inspector. This window displays the values of the instance variables of the current object.
At this point in time it is not possible to view local variables within a method.
From this point there are a variety of options which you can take to take over program control.
Clicking Run executes your code up through the point where either a break point occurs, the program terminates, or the program crashes. If you already have a good idea of where your program is causing errors, you might want to place a breakpoint before that line, and then execute the code until you encounter the line.
You probably don't know where your code is beginning to generate errors, and will want to start with another one of the tools.
The Step Over button executes your code one line at a time. This is very useful (and sometimes tedious, if you have to step through hundreds of lines of code) for tracking the exact values of instance variables.
If in your trace through the file you encounter a call to a subroutine, the Step In button moves the trace into the subroutine.
To move out of the subroutine, and continue the trace at the source of the call click the Step Out button.
Note that clicking this does not exactly cause the program to jump back to the source of the call. The subroutine's execution is finished, and thus any computations performed on variables are still in scope.
The Step Over Continuous button is basically the combination of the Run and Step Over buttons. Basically it runs through your program line-by-line, but never steals control away from the user.
While the Run button only stops program execution when it hits a breakpoint (or in the other cases stated above), it is possible to stop this operation with the Stop button on the debug tool bar. If in the course of this operation your code involves a call to a sub-routine, the debugger will not show what is happening in that call. The sub-routine will, of course, still be executed, but this will all happen behind the scenes.
If your debugging needs involve the examination of all sub-routines, the Step Into Continuous button will bring you through all sub-routines one line at a time. Again the Stop button pauses the execution at that current line of code.
If during the course of your debugging, a sudden flash of brilliance tells you the source of your error (or if you just figure it out), clicking the Kill button (aren't Geeks violent?), returns you to the text editor. Remember that once the debugger is enabled, it must be manually disabled for normal execution.
Well as is obvious, Roaster is quite an advanced program. It does have a way to go, but the developer release program makes your investment well worth it. Unfortunately Natural Intelligence is not too forthcoming about details of exactly when new enhancements will be released; they do say the DR2.0 will incorporate a class browser, and will have complete Applescript support. It also will let programmers use the java.net classes, and finally the term programmers will extend to 68 K programmers with this release.
Natural Intelligence is also to be commended on their technical support; a post to their mailing list at java-mac@natural.com is usually answered by a competent staff member within 10 hours. When I was first starting to use Roaster, I was constantly posting questions to the group, only to have my problems solved right away!
For technical support for our books and software contact support@mcp.com
Copyright ©1996, Que Corporation