MS Visual J Plus Plus v6 includes an amazing set of new and powerful features. While retaining support for Web development, Visual J Plus Plus v6 turns Java into a first-class language for Microsoft Windows apps development.

Programming MS Visual J Plus Plus v6.0 contains the complete and simple explanations—together with numerous examples—that you'll need to master each new feature of this powerful and exciting new tool.

Why Did I Write this tutorial?

Before I first came into contact with Visual J Plus Plus v6, I thought I knew something about Visual J Plus Plus. After all, I had written the manual for Visual J Plus Plus 1.0, Learn Java Now. It's true that Microsoft had skipped from version 1.1 to 6, but surely that was more of a marketing decision than a technical one. How different could one version of Visual J Plus Plus be from the other?

One look at the new Visual J Plus Plus, with its Microsoft Visual Studio 6 user interface, taught me how wrong I was. At first glance, the new Visual J Plus Plus seemed to have more in common with Microsoft Visual C++ and Microsoft Visual Basic than it did with Visual J Plus Plus. Once I got beyond the initial shock, however, I realized that this was still Java; it just had a new, more powerful user interface and included the new Microsoft Windows Foundation Classes for Java (WFC) class library.

It was clear to me that Visual J Plus Plus v6, with its new focus on app development, would become an important environment for developing Windows apps. However, I felt that the typical Java programmer would have a lot to learn before he or she would be in position to fully utilize all that the Visual J Plus Plus v6 package has to offer.

Java and apps: Isn't That a Misprint?

As every Java programmer knows, Java supports two different types of programs: apps and applets. apps are programs like those generated by other programming languages. apps are meant to be invoked from the command line or by being double-clicked within a windowing environment like Microsoft Windows. Applets, by comparison, are designed to be run from within a Web page by a browser such as Microsoft Internet Explorer.

Historically, Java applets got all the press. After all, applets can generate those cute features like the scrolling marquees and bouncing balls present in more and more Web pages. Besides, the Web is considered sexy.

Visual J Plus Plus v6 changes this "applets-only" way of thinking. Visual J Plus Plus v6 turns Java into a first-rate language for developing apps. It adds the powerful new WFC library. An efficient new Forms Designer provides drag-and-drop rapid app development (RAD) access to this library. Additionally, Visual J Plus Plus v6 adds such features as direct access to the Win32 API, easy creation of custom toolbox controls and ActiveX controls, and Java access to Dynamic HTML (DHTML).

Aren't there already good languages for Windows apps?

Prior to Visual J Plus Plus v6, Windows apps programmers had essentially two language options: Visual Basic or C++ (which comes in various flavors, the most popular flavor being Visual C++). Both of these languages have problems for general Windows app development.

Visual Basic has an extremely powerful user interface. Programmers can create simple Windows-based programs quickly and easily. Grab a few icons off of the toolbar and drop them in the Forms Designer, add some code to handle the input or output, and you are just about done.

The problem with Visual Basic lies in the underlying language. The Basic language doesn't encourage the development of organized, structured programs. Some of the very features that make Basic so adept at writing small programs make Basic difficult to use on larger projects. This has led to the common opinion in public programming circles that for large projects Visual Basic simply "runs out of steam."

Visual C++ lies at the opposite end of the development scale. As the saying goes, "if there's something that Visual C++ can't do, it's just not worth doing." Visual C++ is everything that Visual Basic isn't. It's powerful, it supports large programs, and it's object-oriented.

At the same time, Visual C++ is full of traps and pitfalls—so much so, that there was once a popular tutorial devoted entirely to the topic. Add to this that Visual C++ is difficult to learn. As a teacher of C++, I know firsthand how hard it is for even experienced programmers to master the language. To gain rapid acceptance by the marketplace, C++ leveraged the popularity of its non-object-oriented predecessor, C. As C++ has tried to add new capabilities, its slavish support for C has forced the language into a number of linguistic mazes. It is these traps that make C++ so difficult for the uninitiated.

Finally, until very recently Visual C++ has lacked many of the RAD features of Visual Basic. While Microsoft Foundation Classes (MFC) eases the pain, developing simple Windows apps in Visual C++ is still not nearly as simple as with Visual Basic.

Why Java?

Visual J Plus Plus v6 fits comfortably between these two proverbial powerhouses. Visual J Plus Plus v6 has all of the RAD features that make Visual Basic so popular. Developing simple Windows apps under Visual J Plus Plus v6 is a breeze. Unlike Basic, however, Java is well structured, so it supports the development of larger programs.

At the same time, Java is a much simpler language to learn than Visual C++. Java has not tried to remain compatible with some non-object-oriented predecessor. This has left Java free to adopt a clean syntax without the ditches and potholes into which even experienced C++ programmers can fall.

Why Windows-specific?

The fact that Visual J Plus Plus v6 includes WFC to add support for Windows-specific development is surely the most controversial aspect of the language. I like platform-independent solutions as much as the next guy, but when Visual J Plus Plus v6 is viewed in the light of its importance as an app development environment, the inclusion of WFC is easier to understand. If Visual J Plus Plus v6 is to have a chance as an app development tool, its output has to be able to compete with that of Visual C++ and Visual Basic.

Is it possible to write Windows apps in Java using the platform-independent "Java standard" Abstract Windowing Toolkit (AWT) or using the closely related Java Foundation Classes? Sure. Are they as attractive as other Windows apps? No way. This is not meant as an endorsement of Windows apps over those of Motif or Macintosh or any other windowing environment. Nor is this meant as a slam of AWT. A generic solution like AWT can't compete with WFC when generating Windows apps.

For Whom Was This tutorial Written?

This tutorial was written with at least three different types of readers in mind.

Java programmer

First there are the Java programmers. This group includes both users of earlier versions of Visual J Plus Plus as well as users of other Java environments. Since this is probably the largest single group of readers, I have dispensed with the usual introductory chapters on Java syntax. From the beginning, Programming MS Visual J Plus Plus v6.0 takes you through the features of Visual J Plus Plus until, by the time you reach the end of the tutorial, you'll be in a position to utilize just about every feature that Visual J Plus Plus v6 has to offer.

Visual J Plus Plus v6 does introduce a few new wrinkles to the Java language, however. To address this fact, I have added a note—that looks like this note does—to flag language features that are unique to Visual J Plus Plus v6 or which might not otherwise be obvious to the reader.

Visual C++ programmer

A second group of readers are Visual C++ programmers who are curious about this Visual C++ cousin. Maybe Visual C++ has proved a little too complicated or perhaps the lure of Visual Basic's powerful RAD features is too much to resist. This reader is looking for a simpler language with powerful development tools but doesn't want to abandon the C++-like syntax by making the jump to Visual Basic.

Programming MS Visual J Plus Plus v6.0 is ideal at helping this reader migrate to Visual J Plus Plus v6. The similarity between the Java and C++ syntax means that the examples presented here are understandable to the C++ developer.

There are a few language features that the C++ reader might not understand right away. In these cases I have included a special note—that looks like this note does—to explain language differences where these differences arise. Readers whose experience is based in C++ will find that these linguistic cheat sheets will ease their conversion to Visual J Plus Plus.

Visual Basic programmer

Another large group of readers are Visual Basic programmers who are interested in branching out into a more object-oriented language, but for whom Visual C++—with all its turns and bends—is not the answer. For this group I have included a quick overview of the Java language in the appendix. While it may seem like mastering a coding language in a single section is a lot to ask, Java's straightforward syntax makes it simple to learn. Once you've digested Java syntax and mastered the examples in this tutorial, you, too, will be in a position to utilize the Visual J Plus Plus v6 environment.

How Is This tutorial Organized?

Programming MS Visual J Plus Plus v6.0 is divided into three parts.

Part I: Visual J Plus Plus apps

This section describes how to write both platform-independent and Windows-specific console apps in Visual J Plus Plus v6. Even in today's world of windowed, colorful apps, there is no faster way to create a calculation-intensive program for personal use than with the console app.

Part II: Windowed apps

Visual J Plus Plus v6 introduces Java to the ranks of easy-to-use but powerful Windows app development languages. Programming MS Visual J Plus Plus v6.0 teaches the reader how to use the new, powerful WFC library of Windows classes. This part demonstrates how to use such built-in tools as the Forms Designer and the Toolbox to develop fast and colorful windowed apps. The final chapter of this part explains how J/Direct gives the Visual J Plus Plus v6 programmer access to any user-developed dynamic-link library (DLL) in addition to the entire Win32 API.

Part III: Special Topics

This part explains how to create database apps using the Visual J Plus Plus v6 support for ActiveX Data Objects (ADO) 2.0. This makes it easy for Visual J Plus Plus programs to access common Microsoft databases such as Visual FoxPro (included in Visual Studio Enterprise version), Access, SQL Server, and non-Microsoft databases such as Oracle. There is even support for text-based databases.

This part also demonstrates how to create new Toolbox objects with their own properties and events, and how to convert these toolbox tools into ActiveX components. The remaining chapters in this part explain in detail Visual J Plus Plus v6's support for the Web. This discussion includes applet development and WFC support for Dynamic HTML on both the Internet browser and the Web server. Comments