HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

Welcome to Your New Language
One can assume that if you're reading a journal devoted to Java you've taken the first steps into this relatively new and emerging language that has filled up many columns in every major trade magazine since its release only a couple of years ago. You've seen the hype, read the leaflet, digested the ads and got the T-shirt! At this stage, you know Java is the language of the future, with its built in security and communication. Its ability to run on any platform supporting the runtime environment has been well publicized. You now want to join the throngs of developers who are churning out Java code 24 hours a day worldwide. But where do you begin?

The simple answer is, here. This is where the journey to Java enlightenment begins. But before we begin, let's get our essentials together. The first tool that is required in any developer's inventory is a compiler. This piece of software takes the source files and translates them into something that can be run by the Java runtime environment. Next, a text editor of some sort would make physically writing the source files a lot easier. Finally, in case the machine we are developing on doesn't have a Java interpreter, we need one just in case.

So we're ready then? Good, let's get started. Hold on a minute, this isn't the Dark Ages. We don't need to fumble about with command line-driven compilers or put up with basic text editors whose major feature is the ability to Tab correctly! This is the age of the GUI: the ability to see what you're doing in fancy fonts, differing colors and countless windows. What we need is an integrated developing environment that will aid, not hinder. A tool that will allow us to drag and drop objects into place. A tool that will provide something more sophisticated than print statements for debugging. Fortunately, such a tool does exist and it is an essential component of any Java developer's library: Symantec's Visual Café Pro.

This fully integrated Java development environment is one of the most popular IDEs in use today. Some 60 percent of developers are using at least one of the Visual Café range to produce their Java code. So in choosing this you will be in good company. Pop in the VC Pro CD and you are ready to begin. This column will be used to teach Java to the developer, using Visual Café Pro. Each article will travel a little further along the road, detailing features and techniques that make Visual Café Pro the only real choice for developing your Java code. As we will see in later articles, VC makes an excellent training companion through its drag and drop interface. But please note, this series is not intended to be a product endorsement, merely a companion for the large number of developers who have chosen to use Visual Café Pro as their development platform.

Installing Visual Café Pro is extremely easy; simply follow the installation wizard. One of the major components of this package is Symantec's dbANYWHERE client/server database access middleware. This makes building database applications a very uncomplicated task indeed, and will be detailed in later articles. Installing the server part of the dbANYWHERE can be performed at this stage or left for later.

One of the nice things about Visual Café Pro is that it is supported on both the Windows and Apple platforms. For a while, it looked as if the Java world had forgotten about the Macintosh developers, with their only choice being CodeWarrior. Now they have another option to chose from.

Unlike other development platforms, Visual Café Pro is the complete package: editor, compiler, runtime environment, debugger, RAD, GUI. Whereas Microsoft's Visual J++ requires Internet Explorer to be installed in-order to run and test applets, VC provides this as part of the IDE. This is especially comforting to the novice, just dipping into Java and not really knowing what components they need and don't need.

A Quick Tour
One of the first things you will notice when running Visual Café is the layout. This is the familiar Symantec trademark of floating windows. Some users like this, some users do not. I personally dislike this and prefer not to have the desktop shine through but as this is my only real gripe, I am prepared to live with it.

Figure 1 shows a typical working environment for the IDE. Arranged at the top of the screen is the main program toolbar. From here, many of Visual Café's features are accessible. The window to the left of the screen is the main project window which lists all the objects that are associated with the current applet. The window along the bottom is the message window, where all compiler output is placed, including any compiler errors that may be generated. The window at the right of the screen is the property window. From here, the selected object's properties can be modified.

Figure 1
Figure 1: Typical working environment

One of the best features of Visual Café is the ease with which applets can be built. Many products claim to be visual and to have a rapid application development environment, but the majority of them fail. Anyone who has used Visual J++ will know Microsoft's idea of visual is somewhat different from the rest of the world's. With Visual Café, the term visual is correctly used, and not as a tool to cash in on the latest marketing hype. VC provides a complete drag and drop interface, allowing components to be easily dropped onto a work space and manipulated, with the code being updated as each item is being adjusted. This is a novelty in itself; J++ requires the user to run a special utility to produce the code from the component builder.

This is only one of the many features Visual Café Pro has underneath its surface. As an example for this first column, let's build a complete applet without looking at or modifying a single line of Java code. (Granted, from a learner's point of view this does nothing to install many of the concepts and inner workings of Java, but having a working example and then working back is the best way to learn.)

First Project Using RAD
If someone claims they built an application without a single line of code, you instinctively think it's not going to be that good or that usable. Be prepared to be surprised. For this example, we will use one of the standard controls that come as part of the IDE, the calendar control. To show how easy it is to build an applet that can run such a control, the drag and drop interface of VC will be used to achieve the results shown in Figure 2, which can then be used in any Web page.

Figure 2
Figure 2: Results of using drag and drop interface to build your applet

The first thing is to create a new project, which is done by selecting the 'New Project' menu item from the 'File' menu. This presents a small dialog box which contains differing project types. Choose the basic applet icon. This then creates a new project and applet form designer window.

Next, we select the calendar control from the toolbar under the Utility tab and drag it onto the form designer. The control will be created as a small square at the position in the form where it was dropped. Selecting the 'Use Preferred Size' to true, from the object properties window, adjusts it to the size the original developer intended it to be. Next, size the form window to the size the applet will initially take and then center the calendar control.

That's the majority of the application development completed. Next, you need to run the applet and see how it looks. This can be done by pressing the 'Play' button on the tool bar. This will run the applet in debugger mode, which will allow you to step through any code or observe the state of variables. But since our example won't be examining the code produced, this functionality will not be called upon. The calendar applet will then be compiled, loaded and run, all in a very short space of time. Gone, it would seem, are the days of making a cup of coffee while you wait for it to compile. There isn't even time to reach for the cup, never mind drink from it.

Your first applet is now complete and ready for mass distribution to the world.

Visual Café has a number of custom controls that have been developed for use in applets or applications. All of these classes have been packaged inside the Symantec package, which can be found in the main class library directory of the IDE. If an applet is to use such a control, like the example shown in this article, then this package must be transported with the applet. This is a simple matter of copying the Symantec class directory to the directory where the applet will be loaded from. The browser will be able to correctly locate the class files for the applet.

Coming Next
As you will have noticed, rapid application development is, as the name suggests, rapid. Although this example was extremely trivial, it highlights the ease and speed with which Visual Café can be put to use Đ literally from the moment it is installed. The learning curve for the IDE is non-existent, which is how it should be. The tool used for learning the language should never take precedence over the language itself; it should always compliment the language.

In future articles, I will look at how to build slightly more complicated applets, looking at how Visual Café can be used to aid code creation. These applets will range from simple animation applets to sophisticated database front-ending applets using the dbANYWHERE set of classes.

About the Author
Alan Williamson is currently co-authoring a book with his colleague Ceri Moran on Java and databases, while running his Java-based company in the UK. He can be reached at www.n-ary.com or [email protected]


All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.