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..
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.
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.
Web pages are graphical and often connected to other sites.
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 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.
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
<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"
<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">
<MARQUEE BEHAVIOR=SLIDE ALIGN=MIDDLE BGCOLOR=#FFFFFF SCROLLAMOUNT=10>
See the latest sports scores, stock prices, comics, and more.
</MARQUEE> </FONT> </TD> </TR> </TABLE> </CENTER>
<P>Welcome to MSN's <A HREF="/letter.htm"><B>web site</B></A>.
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.
See the biggest European football event of the year,
<A HREF="http://www.euro96.com/"><B>Euro 96</B></A>. Stop in at
<A HREF="http://475Madison.msn.com"><b>475 Madison Avenue</B>
</A>, the hot new cyberseries. Check out our
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 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.
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.
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 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.
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.
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.
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.
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.
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.
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
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.
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.
Java is considered architecture neutral in that a Java program is not written for a specific machine but rather for the universal virtual machine.
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:
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:
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.
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.
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:
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.
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.
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++ 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.
Visual J++ sessions can appear confusing to newcomers.
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:
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 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.