- Using Visual J++ -

Chapter 1

Java and Visual J++

Even Internet old-timers are new to most evolving Internet products. Whether Internet newcomer or pro, Java technology is still a mysterious unknown to most Internet users and programmers. Microsoft decided not to be the first on the market with a Java tool. Microsoft's delay let the software giant produce one of the most powerful, integrated, and workable Java tools available: Visual J++.

This chapter explains what the Java hype is all about, discusses how Microsoft's new Visual J++ platform improves upon the Java standard, and explores the Visual J++ technology in a way that prepares you to use it as soon as possible. As I have explained in the introduction, this book is a true user's book. A Visual J++ user is both the programmer who writes Visual J++ applications and the Internet's end-users who use the technology that Visual J++ provides.

Get ready to learn about Visual J++, one of the most powerful Internet products ever developed..

Get Ready for Visual J++: What's It All About?

We could jump right into Visual J++ and write an application here in chapter 1, but doing so would do most readers a disservice. Despite the popularity of the Internet and the huge number of newly-added users each month, the Internet is still in its infancy.

Hardly anyone is a true Internet expert due to new Internet technologies, such as Visual J++, that emerge almost daily. Most Internet consultants specialize in only one or two areas of the Net; it simply has not been around long enough for a complete mastery by most people.

Fortunately, one does not have to be an Internet guru to take advantage of the Internet by exploring its sites. In addition, you don't even have to have a degree in programming to tackle advanced Internet topics, such as creating Web pages and using Visual J++. People will be able to use Visual J++ on many different levels, creating Internet sites and applications from many different points of view and with different goals in mind for the end-user. You might use Visual J++ to add simple interaction to your Internet development or you might use Visual J++ to write complete stand-alone applications that you sell to end-users.

The following sections explore some of the history that is indispensable to mastering Visual J++. Visual J++ is more than just a programming language, and yet many people will be able to create applications with Visual J++ without any previous programming experience. To orient you, read the following sections to solidify your basic understanding of today's Internet Web pages. Once you cover the basics, you'll know exactly where Visual J++ fits into the Internet equation.

The Need for Simple Navigation

If you have used the Internet in the last couple of years, you probably explored home pages, those graphical Internet screens with hot spots that you click to move around the intricate Internet. Your Web browsing software takes you on a journey through an intricate graphical maze (a spider web of interrelated connections, hence the term Web). An Internet site might contain several Web pages; the first screen you visit for any site generally is that site's home page. The home page often contains links to other pages on the site and to other home pages on the Internet.

For example, if you visit Microsoft's site at www.microsoft.com, you'll see Microsoft's home page. The mouse cursor changes shape when you move it over a hypertext link to another page or to a definition box, which pops up when you click the mouse. Figure 1.1 shows Microsoft's home page.

FIG. 1.1

Web pages are graphical and often connected to other sites.

This book does not require that you be an Internet guru to understand and use Visual J++. Nevertheless, be sure that you've used the Internet enough to understand home pages and maneuver around the WWW (World Wide Web, or just Web). If you've programmed in HTML (Hypertext Markup Language), you'll be even further ahead of the game. If you've never written HTML code, don't fret because this book explains enough to get by for most Visual J++ developers.

Each page you see on the Web is located somewhere on someone's computer. How in the world does your Web-browser find the correct page? Each Web page contains a unique address called the URL (Uniform Resource Locator). Instead of requiring that you type each page's URL (which can become quite lengthy), the current page's hypertext links direct your Web browsing software to the next URL that you wish to display. Literally, surfing the Web is as easy as flipping through pages in a book.

The Web works a lot like the Windows hypertext help system. By clicking on hypertext links (sometimes called hot spots) or by directing users to another page, you can maneuver throughout the Wide World Web just as you do with online help. Instead of viewing another help screen from your application's directory, however, you could be viewing an Italian museum's images of its masterpieces.

The first Web browsers on the market were known as Mosaic browsers, named after the first true Internet graphical browsing program called Mosaic. Students at the University of Illinois at Urbana-Champaign created Mosaic for the National Center for Supercomputing Applications (NCSA). Mosaic took the Web one giant leap forward, making Web-crawling (Internet style, of course!) accessible to anyone with an Internet connection and the Mosaic software.

A Web page might contain text, graphics, and even icons you can click to view multimedia events. One of the goals of Web designers is to make Web pages appear uniform no matter what kind of computer (or, more accurately, which platform) the end-user uses to view the page. The HTML language is a machine-independent language that Web page developers use to design Web pages. One page's HTML listing is actually a set of text commands that, when viewed with a Web browser, produces a Web page that conforms to the look the author intended. Listing 1.1 contains the HTML commands that produced figure 1.1's Web page.

Once again, if this is old hat to you, you're well ahead of the game. Nevertheless, this quick Web page introduction will serve us well throughout the rest of the book. This background material, although brief, ensures that all readers will be on the same basic level when the Visual J++ material is introduced below.

Listing 1.1 The HTML commands that produce the Microsoft home page.

<TITLE>MSN Welcomes You To The Internet!</TITLE>
<!--MSN Web Team: RC, New Scripting-->
<!-- This is the Header -->
<BODY TopMargin=20 LeftMargin=5 BGCOLOR=#FFFFFF LINK=#336600
VLINK=#808080 ALINK=#FF0000>
<FONT FACE="Arial, Geneva" SIZE=2>
<A HREF="/maps/msn-home.map"><IMG SRC="/images/msn-home.gif"
ALT="Clickable Map Image" WIDTH=590 HEIGHT=224 BORDER=0 USEMAP="#home"
<MAP NAME="home">
<AREA SHAPE=RECT COORDS="7,36,120,88" HREF=/products/msprod.htm>
<AREA SHAPE=RECT COORDS="7,97,120,141" HREF=http://www.microsoft.com/support/>
<AREA SHAPE=RECT COORDS="7,151,120,198" HREF=/products/intprod.htm>
<AREA SHAPE=RECT COORDS="473,28,576,50" HREF=/tutorial/default.html>
<AREA SHAPE=RECT COORDS="473,64,576,87" HREF=/access/allinone.asp>
<AREA SHAPE=RECT COORDS="473,100,576,124" HREF=/access/ref.asp>
<AREA SHAPE=RECT COORDS="473,138,576,162" HREF=/access/links/other.htm>
<AREA SHAPE=RECT COORDS="473,174,576,199" HREF=/about/msn.htm>
<AREA SHAPE=RECT COORDS="134,4,433,116" HREF=/letter.htm>
<CENTER> <TABLE Border=0> <TR> <TD>
<A HREF="/choices.asp"><FONT SIZE=2 FACE="Arial, Helv">
<B>Customize This Page</B></FONT></A> </TD> </TR> <TR>
<TD><FONT SIZE=2 FACE="Arial, Helv">
See the latest sports scores, stock prices, comics, and more.&nbsp;
<P>Welcome to MSN's <A HREF="/letter.htm"><B>web site</B></A>.&nbsp;
We're introducing <A HREF="http://www.microsoft.com/ie/"><B>Microsoft Internet
Explorer 3.0</B></A> beta, the next-generation architecture for creating
active web content.
&nbsp;See the biggest European football event of the year,
<A HREF="http://www.euro96.com/"><B>Euro 96</B></A>. &nbsp; Stop in at
<A HREF="http://475Madison.msn.com"><b>475 Madison Avenue</B>
</A>, the hot new cyberseries.&nbsp; Check out our
<A HREF="http://www.msn.com/guides/sitesee/"><B>sponsors!</B></A>

Take a moment to see how listing 1.1's HTML commands produced figure 1.1's Web page. The Microsoft home page is fairly advanced so the HTML listing looks a little forbidding at first. Nevertheless, as you compare the HTML code to the home page, you'll soon see that the HTML language is extremely simple.

The terms within angled brackets (< and >) are called tag references (or tag commands). Tag controls are central to the HTML program. Many commands contain a beginning and ending tag (a forward slash, /, precedes an ending tag). The non-bracketed text items are literal constants, such as Web page text that is to appear on the resulting Web page. The tags primarily determine the placement of figures, the location of links to other Web sites, and the formatting of text. For example, <TITLE> marks the beginning of a title and </TITLE> marks the end. Many of the tags in listing 1.1 are formatting tag codes that specify font style and size instructions for the Web browser.

In reality, the tags do not format text: they offer instructions that your Web browser is to follow. Therefore, when your Web browser sees the <CENTER> tag, your Web browser knows to center the text that runs up to the subsequent </CENTER> ending tag.

When you navigate to a Web page, the server sends to your browser only the HTML text, not the graphical image of the Web page. Your browser then reads the text and responds to the commands by formatting text appropriately and placing links and graphic images where the HTML dictates they should appear. Your browser first receives the full HTML page and then receives whatever graphic images are required to complete the page. Most browsers offer a Stop button you can press to keep from receiving the graphic images for the times when you don't want to wait on the images but you only want to see the text. In place of those images, your Web browser will display icons that represent the unsent images.

When this book looks at a Web site in detail, simpler Web sites than the Microsoft home page will be offered as examples. You should not get bogged down in advanced HTML commands when learning a new technology such as Visual J++. Even simple HTML commands can produce quite attractive Web pages. For example, consider how simple listing 1.2's HTML code appears. You should have little trouble following the HTML commands even if HTML is new to you.

Listing 1.2 Simple HTML commands can produce nice-looking Web pages.

<TITLE>Your Page Title</TITLE>
<H1>Fancy, yet Simple!</H1><P>
HTML is your key to Visual J++ applications. You will eventually load
Visual J++ programs onto other Internet user's computers through an
HTML tag command pair.<center>
<IMG SRC="Apple.gif" ALT="">
<H1><I><A HREF=www.microsoft.com> Click here to see Microsoft's Web site
</A></I></H1><MARQUEE >This text scrolls across the screen</MARQUEE><P>

Figure 1.2 shows the resulting Web page that listing 1.2's HTML commands produce. As you can see, the Web page is attractive and fairly complex looking despite the simple HTML code that created it.

FIG. 1.2

A nice Web page that requires simple HTML.

Why all this talk about HTML? HTML is the vehicle with which you'll eventually link Visual J++ applications to Web pages. As you'll see throughout this book, one simple HTML tag command embeds a complete Visual J++ application into any Web site you create.

The next time you log on to the Internet, locate your menu option that lets you view the HTML source code. If you use Internet Explorer, the source display command is View, Sourc e and if you use Netscape Navigator, the command is View, Document S ource.

Transferring the HTML text listing takes much less transfer time than would transferring a graphical representation of the page. Your browser reads the HTML commands and then formats the text or graphic images according to their instructions. Although your browser must be more capable than a simple graphics viewer, your CPU's time is much less precious than modem downloading time.

Although several tools exist to create Web pages using modern graphical cut-and-paste methods, you can create a fancy Web page simply by using a text editor and knowing the HTML language. There are several good books available that dedicate themselves to the HTML language. If you are interested, here are some of the best:

Internet: From Text to Multimedia

The Wide World Web is not the Internet—it is only a tool that dynamically links Web sites to one another and makes for uniform Web retrieval and navigation. The Internet is defined as the collection of interconnected computers all over the globe.
When the Internet first appeared, users had a difficult time locating information on other computers connected to the Internet. One had to be a master of the UNIX operating system to utilize the Internet effectively. Successful Internet usage required a mastery both of your own computer's hardware and operating system as well as a fairly in-depth knowledge of Internet connections. Internet retrievals required sitting at a text-based terminal and issuing commands to get to where you wanted to go.
In the early 1980s, computer users realized that additional tools were needed to make the Internet usable for more people. Not only were early text-based navigation tools cryptic to use, but they were also machine-dependent: an individual user could not often go to another computer and access information using a common interface. Internet developers began linking their information together into a simple hypertext system, which let users jump from topic to topic.
Given the transition of computers in the 1980s from a text interface to graphical user interface (GUI), the development of Mosaic in late 1993 finally provided the necessary commonality and graphic access to give Internet users a mouse-driven, graphical Web-browsing vehicle. In addition, the Web solidified the Internet as a tool usable by the masses—both computer literate users and novices.

Going the Next Step

The colorful, Mosaic-like browsers changed the Internet by taking its technological development out of the exclusive hands of scientific, corporate, and educational researchers. The new Web browsers made the Internet accessible to anybody and everybody with their simple to-and-fro navigational tools and appealing graphical nature. Soon, millions of users all over the world were moving back and forth between Web sites as easily as they moved from page to page in their word processors.

The Mosaic browser filled its job requirements better than anyone could have imagined. Yet, Mosaic is already considered outdated due to the static nature of its screens. In other words, despite the colorful and cross-linked site pages that Mosaic makes available to the world, the pages don't have enough action in them to keep users occupied; more important, the browser technology is too static to make Web sites truly come alive.

Users seem to want more from the Internet than just a distributed set of interconnected graphical screens. Despite the Web's hypertext nature, those hypertext links simply take you from page location to page location without really doing any work for you except finding appropriate data quickly. Users want real computing power coming at them from the Web sites they visit. For example, instead of reading about the rules of chess, you might want to see a chess game in action or get an introductory graphical tutorial on effective opening moves.

Java, developed by Sun Microsystems in the mid-1990s, changes the way that Web sites operate. Java is a programming language with language features similar to C++. Instead of using Web browsers to view data, the browsers seamlessly download programs written in the Java language and those Java programs execute on the user's computer. When you view a Java-enabled Web page, you'll not only see the usual graphical page, but you'll also be able to interact with a program that runs on your own computer, brought to your computer via the Web's connection.

Don't make the mistake of thinking that the sounds and animation you've seen on Web pages represent the Java technology. For example, when you listen to a Web page's sound file, your own computer's sound-producing software is probably playing the sound data that comes from the Web site to your browser. Java takes computer interaction a step further than that.

There are two kinds of programs you can write with the Java language. They are

Most Java programs to date reside in applets. After all, the primary goal of Java is to place executable code on Web pages so that users gain more interactivity with Web sites. In addition to writing applets that appear in your Web pages, you can also create stand-alone programs that execute without the need for a Web browser. For example, if you wanted to write a rental property management application that ran independently of an Internet connection, you could select Java as the programming language you use to develop the application.

Java Provides Executable Content

When working with Visual J++ and Java, you'll often hear and read about executable content. Executable content is what Java is really all about. A Web page contains executable content, via HTML commands, in the form of a Java applet. Any web page's Java content is executable on the target user's computer. Figure 1.3 shows an overview of an HTML document with two embedded Java applets.

FIG. 1.3

HTML serves up Java's executable content.

When the end-user enters the URL that displays figure 1.3's page (or hypertext links to the page), the user's Web-browsing software loads the HTML code, formats the page's text according to the HTML tags, displays any graphic images that appear on the page, and loads the executable content (applets) so the content can execute either immediately or upon a pre-determined event, such as a mouse click over a hotspot on the Web page.

As you'll see in this book's code, the <APPLET> tag indicates that a Java-enabled applet appears inside HTML.. The Java code follows the <APPLET> tag until the closing </APPLET> appears. <APPLET> replaces the older <APP> tag used in previous releases of Java.
You will only be able to run applets if you have a Java-enabled browser, such as Microsoft's Internet Explorer 3.0 or Netscape Navigator 2.0 or later.

The best method of running Java applets is not always obvious to the end-user. The user might think he or she is viewing a busy Web page when, in reality, an applet is providing animation. The look of that animation is smooth because the animation software runs on the user's computer. Because of the applet, the speed of the animation is not dependent on the download time or on Internet traffic.

Before Java-enabled Web pages, the user did have some interaction with the remote site. Nevertheless, that interaction was severely limited. Web page animation was controlled by the user's animation software: if a computer system had no software that could display animation, that feature of the Web page was lost for that system's users.. If the user were to interact with the remote site in a question-answer session, such as in order-taking, the user would often have to fill out the form completely before error-checking could be done to any of the user's responses. The user would have to trigger any and all interactions with the remote site; the response would then be limited to the remote site's speed and the current traffic flow on the Internet.

CGI programming (Common Gateway Interface) programming provides for the primitive interaction you often see on non-Java Web sites.

Surely, you have traveled into a remote Web site, downloaded software, and then logged off to execute that software. Java makes this process seamless. When you travel to a remote site, the software you want to run can run without your doing anything at all. In addition, the software applet automatically downloads itself to your computer, runs when you trigger its execution, and then goes away when you leave the Web site without taking up permanent disk space! Think of the possibilities for software developers: You'll be able to test-drive software without running an installation program and without having to remove the software when you finish the demonstration.

Multi-Platform Executable Content

Now that you've seen how Java-enabled Web sites appear to the user, think about the requirements of such executable content. When you write a Java-based Web page, you want the code to work on the end-user's remote computer no matter what kind of computer the remote user uses. Successfully writing a single program that compiles and operates on multiple platforms is almost impossible and yet, Java easily accomplishes the task.

A Coding Background

Before going further, you may need a review of programming terms if you are new to programming or your skills need refreshing. A program is a set of instructions, written in a programming language such as Java, that tell the computer what to do. Both Java applets and Java applications are programs.
You'll use Visual J++ to write the code, or program instructions, that will form your Java programs. Once you write the code, you'll have to compile the code. No computer can really understand a programming language such as Java. Programming languages exist for humans. When you compile the program, the compiler (Visual J++ includes a compiler) translates your human-readable code into machine-readable code.
Due to the virtual machine nature of Java (see the text that follows this sidebar), Java code is not completely compiled but the Java compiler compiles the code into an in-between stage called bytecode. Your Java-enabled Web browsing software then translates this compiled bytecode into instructions that your computer can then execute.

The secret to a Java program's multi-platform operation is bytecode. Whereas most programming compilers such as Visual C++ and Visual Basic compile code into a machine-dependent executable program, Java development tools such as Visual J++ do not go quite that far. All Java compilers compile your Java instructions into a special machine-independent module called bytecode.

No computer can really read bytecode but each computer's Java-enabled browser can. In other words, given the same Java applet bytecode, a PC can run the applet using Internet Explorer 3.0 and a UNIX-based minicomputer can run that very same bytecode by using its own Java-enabled browser such as HotJava. Each Web browser actually interprets the machine-dependent bytecode and then translates that bytecode into machine-specific instructions that particular computer can understand.

Figure 1.4 shows the Java compilation/translation scenario. You'll use Visual J++ to write Java code for a virtual machine, you'll then instruct Visual J++ to compile the code into machine independent bytecode that follows the Web page that is to contain the applet, and when the end-user requests that Web page, the user's Web browser reads the bytecode and automatically interprets the bytecode into code readable by the user's computer. The user is unaware that all this took place; he or she simply displays the Web page and sees the executing applet along with the rest of the Web page's content.

FIG. 1.4

Your Visual J++ session produces compiled bytecode that subsequent computers translate.

The idea is that you're not writing for one particular real computer, but a universal computer that represents all computers (at least all those that support a Java-enabled Web browser). This universal computer, called the "virtual machine," only runs the bytecode. Each computer's Java-enabled Web browser software translates the bytecode into machine-readable code.

The Web browser automatically runs the Visual J++ applet. Some applets run automatically, and some run in response to a user event such as a mouse click. It's important that you realize that the user does not necessarily know or care that a small program is running. To the user, the Web page simply does more and responds much more quickly, as fast as the user's computer can translate the bytecode's executable content. All traces of the program then go away when the applet ends, or when the user leaves the Web page.

When you want the fastest response time possible for a user's interaction with a Web page, you will almost certainly want to use Visual J++ to write a Java applet. Although the user still has to wait for the Web page to download, and although the user still has to wait for the bytecode to get to the computer, the applet (the Web page's executable content) executes as quickly as the user's computer can run the applet. The user is no longer bound to download time once the computer gets the executable content. All other forms of Web page interaction, such as Web page interaction written in CGI, are slaves to download response time and current Internet activity.

Java is considered architecture neutral in that a Java program is not written for a specific machine but rather for the universal virtual machine.

The Java Usage Summary

If you are new to Java technology, as most people still are, you might appreciate a summary of the process one goes through when they viewing a Java-enabled Web page with a Java-aware Web browser such as Internet Explorer. Here are the steps that occur:

  1. You log on to the Internet, using your Web-browsing software.
  2. You see your Web browser's default home page.
  3. You enter a Java-enabled Web site's URL (location) to view.
  4. The serving computer sends to your Web browser the HTML document.
  5. The document's <APPLET> tag informs your Web browser of the Web page's Java-based executable content.
  6. Your Web browser downloads graphic images from the server, if any graphics appear on the Web page.
  7. Depending on how the Java applet is to be triggered (either automatically or by a user's event), the server will also send the bytecode to your computer (the target) when the time is right.
  8. Your computer's Web browser interprets the bytecode and executes the Java executable content.
  9. When you leave the Web page, the executable content goes away. (Some Web browsers will keep the Java code in memory for a while in case you return to the page.)

Perhaps this would also be a good time to explain what you, a Visual J++ developer, will go through when creating Web pages with Java applets. Here are the general steps you'll follow:

  1. Start Visual J++ if you have not already done so. (Starting Visual J++ actually means starting the Developer Studio, a complete programming language development support system.) You'll learn how to install and start Visual J++ in chapter 2, "Getting Started with Visual J++."
  2. Create your Java applet.
  3. Create the HTML Web page that will contain the Java applet. Use appropriate tags to indicate the applet and its parameters.
  4. Compile the Java applet. The Developer Studio keeps track of Java applets using the project concept. You'll store each applet in the project and all associated files for that project will also reside in the project, including the HTML Web page.
  5. If the compiler finds errors, fix them and recompile the project's files.
  6. Test your applet. You can test Visual J++ project applications without logging onto the Internet. If the Java applet does not do what you intended, fix the problem and recompile the applet.
  7. Store the applet and HTML on your Web server, where it will await an Internet user's request.

Multithreaded Applications

A multithreaded application is a program that might spin off into more than one thread, or a single line of execution. Without multithreading, a program can only execute sequentially. Many programs, however, might be able to perform multiple calculations or processing of tasks in parallel. Of course, if one calculation depends on a the result of a second calculation, both cannot execute in parallel because one must complete before the next calculation can begin.

You've already experienced multithreading if you've navigated through the Web. You can be reading and scrolling through text while graphic images are loading elsewhere on the page. In addition, you can download a file or image by clicking on an icon and then, while the downloading takes place, you can start the download of yet another image or file.

As you develop Java programs, Visual J++ lets you specify various threads that can act independently of one another.

Don't be fooled. At its lowest level, a computer can only execute one instruction at a time. Nevertheless, computers run so quickly that they can appear to perform more than one task at the same time. Although there are a handful of computers that contain multiple processors, these multi-processor computers are not yet in the mainstream; most people still use a single processor machine.

No More Missing Viewers!

A Java applet can deliver two separate items that will make Java-based Web pages more successful and popular than those Web pages that are not Java-enabled. Your Java-enabled Web page can transmit a protocol handler to the end-user's computer that accepts downloaded data in a format that the user's computer would not otherwise be able to receive. For example, if you decide to transmit data to your Web page, and you transmit that data using a special error-correction protocol that you developed to match your particular data format, you'll be able to send first a protocol handler that explains to the target computer how to receive the incoming data.

Your users will not have to know about the protocol handler either. Think of a protocol handler as an automatic protocol selector. For example, if you've ever downloaded a file from a BBS, you've probably had to choose a download protocol such as XMODEM or ZMODEM. The protocol that the BBS sends to you must match the protocol you select or the two computers will not be able to communicate. By first sending a protocol handler before sending the data, the protocol handler teaches the target computer how to receive the data so your users will not have to bother with protocol selection themselves.

In addition to protocol handlers, Java-enabled programs can send content handlers to receiving computers. For example, if your Java-enabled page contains a graphic image that resides in your own, new, specially-developed graphics format, you can send a content handler first. For example, if your Web page contains a .gif graphic image, almost anyone will be able to see the images because the .gif format is so common. However, if you send a uniquely-formatted graphic image, you can first send a content handler that teaches the target computer how to display the image; then your Java applet can send the image.

You'll never have to worry about an end-user being able to receive your data or display your graphic images again as long as you provide the appropriate protocol handler or content handler when you send unusual information.

Is Security an Issue?

The answer to this section title's question is that security is always an issue. It could be that Java-enabled applets are prone to security problems. After all, when you visit a Java-enabled Web page, you are not always sure if an applet is running or what exactly that applet is trying to do to your computer's disk or memory.

Fortunately, Sun Microsystems developed Java from inception to be a network-based programming language. Therefore, security is inherent in the language, both for the developer and for the Internet user. What follows are some of the security-related protections built into the Java language:

You can locally load and run a Java applet from your own browser by loading an applet from your own disk drive or network. In the case of a locally-loaded applet, the applet does generally have permission to read and write to the local file system. In addition, some applet viewers do let the end-user specify a list of files that a Web applet can access.

As you can see, Java developers do understand the need for security and the most obvious security footholds are barred from an applet's access. As more people write Java applets, additional security concerns are sure to enter into the picture.

Give Java a Spin

Now that you know more about Java, why not look at a Java-enabled Web page? Use Internet Explorer 3.0 or Netscape's Navigator to locate the following Web site:

This Web site displays a colorful newspaper-like Web page that details current news events of the day called the NandO Times. From this site's URL address, perhaps you can tell that this Web page is a CGI-based Web page as most non-Java pages are. Although the Web page is fancy, the page is static and does nothing more than display text and graphics. Notice the four still pictures at the top of the page.

Scroll down to the list of choices at the bottom of the Web page and look for the choice labeled JAVA VERSION. Click this choice. Once the Java version appears on your screen, you'll see the same Web page as before; the Java version of the page displays an eye-catching scrolling text display of headline news and the four graphic images change regularly (about once a second - fast for the Internet). Figure 1.5 shows the Web page and calls out where to find the moving text and images when you browse the NandO Times Web site.

FIG. 1.5

In the future, if you want to go directly to the Java-based NandO Times page, set your browser's URL address to:

The flashing graphic images and the scrolling text do not come from a CGI program that is behind the Web page. You are seeing the results of a Java applet that the server sent to your computer along with the HTML page when you requested the Web page. Your computer is running the code that scrolls the text and changes the graphics.

Visual J++ Takes Java Further

Visual J++ is not a Java competitor. Microsoft makes it very clear that the Visual J++ technology supports the entire Sun Microsystems- developed Java language. Visual J++ is a programming platform used to develop Java-enabled applets and applications. Visual J++ includes not only a Java compiler (the tool that translates your Java programs to bytecode), but also an editor, debugger, and online documentation provider. (The end of this section explores Visual J++'s features more fully.)

Therefore, if you already know Java, you'll feel at home with Visual J++ once you learn Visual J++'s interface. Learning Visual J++'s interface,may at first seem extremely difficult. Figure 1.6 shows a sample Visual J++ session. The numerous windows and screen elements often frighten the novice programmer, but you'll soon see that the Visual J++ tools are there to make your life easier, not more complicated.

FIG. 1.6

Visual J++ sessions can appear confusing to newcomers.

This book takes its title seriously! Instead of a dry in-depth explanation of every Visual J++ feature, command, and option, this book shows you how to get up and running quickly with Visual J++, so that you'll be using the system as soon as possible. This book will explain the most common components of the Visual J++ system and then dive into Visual J++'s uses and programming fundamentals. You'll find that this book's hands-on approach makes using Visual J++ a pleasure from the very beginning.

The early Java compilers were command-line based. Surprisingly, the graphical nature of computers and the Web did not make it to the Java language development tools until programmers used Java for about a year. In late 1995 and early 1996, graphical Java development tools began to appear on the market.

Microsoft was not the first on the market with a Java development tool. As a matter of fact, Microsoft entered the Java race fairly late in the game. Although late, Microsoft did things right when they introduced Visual J++.

Keep in mind that Visual J++ is not a Java replacement.Nor is Visual J++ a competing product to the Java language. In fact, Microsoft makes it clear that Visual J++ implements the very same Java technology developed by Sun Microsystems. Therefore, when you work with Visual J++, you are working with the Java language, just as Visual C++ programmers write code in C++. Visual J++ is a complete development platform, or program development tool, with which you can create Java-enabled applets.

The following are just a few Visual J++ features you'll find and use:

Visual J++ uses the same development platform, the Developer Studio, that other powerful Microsoft development languages are also used by Visual C++ and the FORTRAN Powerstation. Although the Developer Studio is Windows-based, that is, you must have Windows to use the Developer Studio. Java applets and applications that you create can run on any Java-enabled platform.
If you've studied Java before, you may have heard of content and protocol handlers that the Java supports. A content handler teaches a Web browser how to display new kinds of data and a protocol handler teaches a Web browser how to send and receive data using various formats. Although the Java language portion of Visual J++ lets you write content and protocol handler development, Visual J++ does not support content or protocol handlers. The only Web browser on the market that does support the two handlers is HotJava, a Sun Microsystems product. Visual J++'s ActiveX and COM technologies replace content and protocol handler requirements.

Get Ready for Visual J++

Now that you have a brief historical background of the Java language, you know how Java applets and applications fit into the world of the Internet. Java applets travel along with an HTML document and execute on the end-user's computer. That execution gives you the ability to produce much more real-time Web page action, which could include the following interactive content:


The goal of this chapter was to provide you with an introduction to Java technology and to the Visual J++ development system. You now know that Visual J++ is not a Java replacement, but a Java development system with which you can create robust interactive Internet applications. Now that you've mastered an overview of the features and functions of Java and Visual J++, you're ready to jump right into the Visual J++ Developer Studio in the next chapter and learn how to maneuver through Visual J++ and take advantage of the power you'll find in Visual J++.

The following points were covered in this chapter:

Previous Page TOC Next Page

| Previous Chapter | Next Chapter |

| Table of Contents | Book Home Page |

| Que Home Page | Digital Bookshelf | Disclaimer |

To order books from QUE, call us at 800-716-0044 or 317-361-5400.

For comments or technical support for our books and software, select Talk to Us.

© 1996, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon and Schuster Company.