| Developer's Daily | Visual Cafe Education |
| front page | java | perl | unix | DevDirectory |
Introduction
When I first started using Visual Café I was faced with the problem of how to work with the Java classes I'd already created. The first time I opened one of my Java source files into Visual Café using the File|Open menu, the Project menu selection (which contains the Build and Compile commands) disappeared! Even though I was looking at my Java source code in the Visual Café editor, there was no way to compile it in this environment.
My first approach to this problem was to edit the file in the Visual
Café editor, then save the file after I made my desired changes.
After each save, I'd compile the file at the DOS command line using Sun's
Java compiler (javac). When the compiler complained of errors, I'd
go back to the source code and manually track them down. Needless to say,
this was not a productive environment.
A Better Way
Definitely in need of a better way to do things, I dug deep into the Visual Café documentation. Unfortunately, what I suspected was true: I could not compile a Java source file in the Visual Café environment when I opened it this way.
Fortunately, if you want to edit, compile, and debug a Java source file visually, there is a solution, and it's very simple.
The only requirement is that you must first create a Visual Café
"project" to work in the visual environment. After you create
a project, you import your Java source file(s) into the project environment,
where you can edit, compile, and debug the Java source code using all of
Visual Café's powerful visual tools.
A Quick Example
As a quick example, let's assume for a moment that I have a Java source file named FileIO.java that I want to work on in the Visual Café environment. This file contains some useful Java code, but it's not an applet or an application -- it's just some code that I want to work on. Instead of opening the file directly using File | Open like I used to, I just need to add a few short steps to the opening procedure so I can edit/compile/debug the file visually.
The first thing I do after starting Visual Café is to create a new project by selecting New Project … from the File pulldown menu. In the New Project dialog, I click on the Empty Project icon, then select OK. Visual Café responds by opening an untitled Project dialog window.
Once the Project window is opened, I select the Insert pulldown
menu, and then choose the Files into Project… option. From
the Project Files dialog I just navigate through my directory structure
until I find the FileIO.java file. In fact, if I needed
to, I could select multiple Java source files to modify within this one
project. Once the file is loaded, I'm ready to start working visually.
Conclusion
While this approach requires a few extra steps, it's well worth the
effort. Once my Java source files are loaded into a Visual Cafe project
like this, I can take full advantage of the powerful visual edit/compile/debug
tools the environment offers. This is a tremendous improvement over
the command-line model!
[Note - This article first appeared in ZD Journals Visual Cafe Developer's Journal. The article is reprinted here with their permission. The author now works for Developer's Daily.]
Copyright © 1998 DevDaily Interactive, Inc.
All Rights Reserved.