صفحة 2 من 3 الأولىالأولى 123 الأخيرةالأخيرة
النتائج 16 إلى 30 من 36

الموضوع: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

  1. #16
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 4

    Java Animates Web Pages

    The Java language and Java-enabled browsers allow a more visually dynamic Web than possible before. Instead of hypertext pages containing only still images with helper applications to display video, Java Web pages can include animated graphics, text, and any moving visual elements a Java programmer can dream up.

    This chapter surveys several Java applets that implement animation. In some cases, the chapter also includes key portions of the source code to demonstrate how these applets are made. If you want to understand these code portions in more detail, you can read more about Java programming basics in later parts of this book. If not, you can skip over the programming sections for now and return to them later. If you’d like to try out the applets described here, you should be familiar with Java’s connection with HTML as described in Chapter 2.

    The purpose of this chapter is to familiarize you with the many types of animation possible using applets. If you are ready to place applets on your Web pages, this chapter will also be invaluable to you; it contains instructions for including some publicly available demonstration applets that you can customize and include on a hypertext page.

    A TREASURE TROVE OF JAVA APPLETS</FONT>Visit the Gamelan web site at http://www.gamelan.com/ to connect to a well-organized, frequently updated, and very comprehensive registry of Java applets, demonstrations, and documentation. This collection includes pointers to many of the demonstrations discussed in this book.

    Applets in Motion

    If you are a new user of a Java-enabled browser, you will immediately notice that some Java pages contain moving text, figures, and animations. These moving images are made possible by Java applets that implement Java’s Runnable interface. These applets don’t just display static text or graphics; they can execute their content continuously.

    NervousText

    One example of animated text is the NervousText applet. NervousText was originally developed by Daniel Wyszynski at the Center for Applied Large-Scale Computing. Wyszynski’s NervousText applet displays HotJava! in jostling on-screen letters. David Leach modified this applet so that it can display any programmer-defined string. Figure 4.1 shows both Wyszynski’s and David Leach’s NervousText applets on a Web page.

    [img]file:///D:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.1.



    The Nervous Text applet.

    The NervousText applet is a good demonstration of how an applet can be included on any Web page, not just Web pages created by the applet’s developer. You are not limited to using only applets that you write. You can modify and use other developer’s applets from their sites, just as you link to hypertext pages at other sites. In fact, sharing applets across the Net is what Java’s capability to distribute executable content is all about.

    You use the APPLET tag in HTML to place a publicly available applet in a Web page. The Codebase attribute identifies the path (using a Uniform Resource Locator, or URL) to a Java class anywhere on a publicly available server on the Net. The Code attribute then specifies the applet’s class name.

    In general, the APPLET tag on an HTML page works like this:

    <APPLET Codebase = “path (URL) of directory containing class files” Code = “name of class file” Width = “width of applet in pixels” Height = “height of applet in pixels”> <PARAM Name=”parameter name” Value=”value of parameter”> <PARAM Name=”parameter name” Value=”value of parameter”></APPLET>In Figure 4.1, Leach’s modification uses a parameter called msg to set the value of the message that the applet displays.

    You can include a beta version of a NervousText applet in your page like this:

    <APPLET Codebase=”http://www.javasoft.com/JDK-prebeta1.../NervousText/” Code=”NervousText.class” Width=”200" Height=”50"><PARAM Name = “text” Value=”HotJava-Beta”></APPLET>Note that the parameters use the PARAM tag in HTML, and that these parameter tags occur between the opening <APPLET> tag and closing </APPLET> tag. When the Java-enabled browser reads the PARAM attributes Name and Value, it passes these values to the applet.

    USING JAVA APPLETS WITHOUT JAVA</FONT>You can put together a Web page that includes applets you didn’t create or at any location using the APPLET element. You don’t have to have a Java-enabled browser or the Java compiler to serve applets. You need only a reference to the class file of the applet. If you use applets that are at remote locations, you need to identify where on the Net the class file for the applet exists. To do so, use the Codebase attribute of the APPLET tag. Of course, users who do not have a Java-enabled browser cannot observe the applets.

    If you use a remote applet in this way, consider downloading and serving a copy of the class file from your own site. Before taking this step, however, check with the information provider. And, of course, check out the applet’s behavior—it is executable content and runs on the computer of anyone requesting to view it.



    David Leach’s modification of NervousText demonstrates the programming technique of passing values to the applet with parameters. In the Java applet code, David uses the getAttribute method to find out the value of the parameter msg passed from the HTML tags to the Java applet. Leach’s class definition includes the data string userString; and the init() method includes this line:

    userString = getAttribute(“msg”);David uses this string in the paint() method to derive the characters that draw the applet. The trick of making the letters “nervous” is to vary their coordinates in the paint() method by using a random number generator for their X and Y coordinates:

    x_coord = (int) (Math.random()*10+15*i);y_coord = (int) (Math.random()*10+36);TickerTape

    Similar to the NervousText applet, another good demonstration of Java’s animation capabilities is TickerTape. This applet was originally developed by Sven Heinicke at HotWired and later modified by David Leach and John Stone at the University of Missouri-Rolla. Many others have subsequently created variations on the TickerTape applet.

    ARE JAVA USERS WASTING BANDWIDTH?After a Java applet’s bytecodes have been downloaded across the network, the user’s host is the processor that interpets them. The information provider’s host works only to distribute the bytecodes. Users of applets, therefore, might typically use far less bandwidth and far less time on the information provider’s computer than might Web surfers.

    Also, class files containing bytecodes aren’t all that large. For example, the TickerTape applet (see Figure 4.2) is 3,186 bytes—easily smaller than many graphics files routinely downloaded from the HotWired server. Therefore, although users may see more action with applets, they are not necessarily using more bandwidth on the Web. Of course, leaving a browser on autopilot (such as in the Surf-o-Matic applet in Chapter 6) and walking away would cause a browser to use much bandwidth for downloading Web pages.

    Information providers must be very careful about the size and processing power required by their applets; a CPU-intensive applet could bring the user’s computer to its knees.



    Figure 4.2 shows the display of the TickerTape applet. The text in the lines scrolls continuously to the left; with the bottom ticker line moving very rapidly.

  2. #17
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    اعتذر للجميع سوف اوقف كتابة الموضوع لبعض الوقت
    وشكرا
    رمضان كريم

  3. #18
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.2.



    TickerTape applet eaxample.

    The TickerTape applet uses a key programming trick to cause the letters to move. The code changes the X position of the string by an amount equal to the speed attribute prior to repainting the string in each cycle. Here’s the code to do this:

    xpos -= speed;This line of code subtracts the value of speed from the current horizontal position of the string. The line is a quick way of writing the equivalent xpos = xpos - speed.

    You can include a beta version of a more elaborate kind of ticker tape on a Web page like this:

    <APPLET Codebase = “http://www.digitalfocus.com/digitalfocus/faq/” Code = “reloadImage.class” Width=”600" Height=”70"> <PARAM Name=”rateOfMovement” Value=”2"> <PARAM Name=”sleepInterval” Value=”40"> <PARAM Name=”msgYLocation” Value=”12"> <PARAM Name=”passedMsg” Value=”Microsoft announces support for Java....Pigs were seen flying in Wyoming.....Martians endorse Java....java to be used in ballot boxes during next elections...”> <PARAM Name=”secondaryMsg” Value=”This just in......Netscape stock fell 20% after Microsoft announced i-net strategy....Next release of PowerBuilder to be java aware.....stay tuned...”></APPLET>Figure 4.3 shows a ticker tape with controls in action.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.3.



    TickerTape applet with controls.

    Fireworks

    Another variation on animation is to have graphics—rather than words only—flash across a page. Erik Wistrand has created an applet that transforms a Web page into a fireworks show (see Figure 4.4).

    Similar to the TickerTape applet, you can include the Fireworks applet on a Web page, and you can control aspects of its appearance. The fireworks parameters set the number of rockets, points, size of points, duration of rockets, and even the constant of gravity.

    This example sets a series of 50 rockets on a page (shown in Figure 4.4). The COLOR parameter uses hexadecimal (base 16) notation to describe the red, green, and blue values of the background image color.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.4.



    Fireworks applet example.

    Animation

    Not all animations involve moving text for aesthetic purposes. Other animations occur in instructional pages or as part of a user’s interaction with a Web page.

    Juggling

    Chris Seguin has created a juggling instructional page (http://www.acm.uiuc.edu/webmonkeys/juggling/) that effectively uses animation to show—rather than tell—how to juggle. You see the juggling page in Figure 4.5. Viewed through a Java-enabled browser, the page shows the two model hands juggling one, two, and three balls. See Chapter 25, which was written by Chris, for more information on animation programming.

    One of the programming keys in Chris’s applet source code is his use of arrays to store the path of the balls. He uses the same ball graphic and repositions it along this path. This is unlike a cartoon in which individual frames would show a ball in its different positions on its path.

    Java programmers use both the technique of using a path for a graphic and frames of graphics to animate graphics. In general, the graphic and path approach leads to less memory drain and more flexibility. Although for complicated or animated images (refer back to Duke in Figure 1.3 in the first chapter), the frame approach is desirable.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.5.



    The Java juggling page.

    Drawing on Famous Pictures

    Another variation in graphics on Web pages is to let you draw right on pictures on a page. Johan van der Hoeven has created the Magic applet, which has a fanciful appeal. You can use it to draw as if you were using a Magic Marker on famous pictures. Figure 4.6 shows markings on a world map and the Mona Lisa (this is an alpha applet).

    WHO OWNS WHAT?The drawing applet in this section demonstrates the blending of authorship and ownership that Java is opening on the Web. The author of the HTML page used an applet written by one person and an image created by another (and painted by still another—Leonardo da Vinci—long ago!) to create an environment for the user to alter the image. Who is the author of the resulting Web page and who finally owns the melded pieces? The talent of the Java programmer who made the applet? The Web page creator who put the pieces together? The browser manufacturer? The user who marks the image? The creator of the original image? da Vinci perhaps never would have imagined his painting would be transmitted around the world to be defaced with such glee. These questions raise just some of the legal and intellectual property issues involved in the use of Java and the Web.[img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.6.



    Marking on the world and the Mona Lisa.

    A Live Feedback Imagemap

    Still another variation on Java graphics is to make images function just like HTML imagemaps; when the user clicks on certain parts of the image, other resources are retrieved. Jim Graham at Sun Microsystems has implemented an applet to demonstrate this capability. Shown in Figure 4.7, this applet demonstrates the equivalent functionality of an HTML imagemap, but with the additional features of live feedback. When a user passes the cursor over a “hot” region of the image, that region appears highlighted to indicate that clicking on it will retrieve another resource or some media content.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.7.



    Live feedback imagemap.

    The Weather

    While the images shown so far are interesting, a more useful example is in Figure 4.8, a live weather map. Created by Alan Steremberg and Christopher Schwerzler, with weather data provided by University of Michigan, this Java applet lets you look at current weather conditions. Figure 4.8 shows the infrared satellite image for the United States. Other options are available, as shown in the figure, for obtaining other weather information.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.8.



    Weather map.

    Commercial Sites Using Java

    The demonstrations in this chapter show many of Java’s animation capabilities. But Java is more than a good show; it is also already at work on commercial Web sites. The Nando Times uses Java (refer back to Figure 1.13), as do George Coates Performance Works (refer back to Figure 1.10), ESPNET SportsZone (refer back to figure 1.14), Dimension X (http://www.dimensionx.com/), HotWired (http://www.hotwired.com/), and Sun Microsystems (http://www.sun.com/). Because Java brings so much visual interest to a Web page, it has great potential to draw attention, convey specialized information, and provide entertainment.

    The Rolling Stones

    The Rolling Stones is a rock band that made a big splash on the Internet Multicast Backbone (MBONE—http://www.eit.com/techinfo/mbone/mbone.html) when they used it to simulcast part of their November 18, 1994, Dallas Cotton Bowl concert. Today, the Stones Web site ( http://www.stones.com/) is making a splash with Java.

    The Stones site contains several interesting Java applets:

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.9.



    The Rolling Stones Voodoo Lounge with Java.

    Accurate Information System Consultant

    Other commercial providers are using Java to add interest to their pages through animation. Accurate Information Systems (http://accurate.com.my) uses Java to greet users with a moving ticker tape and a bouncing ball (see Figure 4.10).

    Of course, just as the BLINK tag and other graphics elements become overused to the point of excess on the Web, so might applets be used gratuitously. The potential for applets to add motion, interest, information, and real service to users of a Web is great, however, and we have yet to realize Java’s full potential.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 4.10.



    Accurate Information System Consultant ticker tape greeting.

    Summary

    You can use Java applets to place animations on Web pages. A user can set the parameters of an existing applet using the PARAM tag and bring a customized applet to his or her own Web page. Developers can create new applets to provide this functionality and make them available for users.

    • Text can shimmer using NervousText. Users can include this applet on their pages by using the APP element. By setting attributes of the applet, the user can control characteristics and behavior of the applet.
    • Text can scroll, as shown in the TickerTape applet.
    • Graphics can repeat a visual pattern, such as in the Fireworks applet.
    • Moving applets can teach a lesson, as in the Juggling applet.
    • The Magic applet enables users to alter graphics, allowing them to draw on an image.
    • A Java applet can perform the equivalent function of an HTML imagemap. Java’s advantage over traditional imagemaps is that Java imagemaps can give instant feedback regarding the user’s cursor position. Feedback does not need to be delayed until after a mouse click.
    • Many companies already use Java, including rock bands and computer companies, to provide interest on Web pages.

  4. #19
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 5

    Java makes web pages interactive

    Java’s capability to animate Web pages is just the surface of what you might first notice when experiencing the Web through a Java-enabled browser. Not only do items move on Java Web pages, but applets can also accept user input through mouse clicks or keyboard entries. Java enables people to create Web pages with embedded puzzles, chemical models, games, and even communication systems. (For some illustrations of these, refer to the figures in Chapter 1.)

    This chapter surveys some Java applets that provide interactivity. These Java applets range from simple games to instructional modules. Because, as of this writing, Java is still in its infancy, this chapter shows just a glimpse of the rich interactivity Java may bring to the Web.

    This chapter also points out key programming tricks used in each of these applets. You can learn the basics of Java programming in Part III of this book.

    WHAT IS INTERACTIVITY?The word interactivity has become a buzzword in media development. Products claim they have it, and developers promise to bring interactivity to various media (television, CD-ROMs, magazines, newspapers, games, and so on). Interactivity has been promised so much that it is nearly as hollow a term as information superhighway—meaning very little and lacking specific illustrations.

    A dictionary definition touches on the main idea of mutual response and reciprocity:

    in-ter-ac-tive adj 1. mutually or reciprocally active; 2. of, relating to, or being a two-way electronic communication system (as a telephone, cable television, or a computer) that involves a user’s orders (as for information or merchandise) or responses (as to a poll). (Definition from the online Webster’s Dictionary.)

    In the broadest sense of the word, nearly everything could be considered interactive. Toasters and televisions, for example, respond based on a user’s orders.

    Richer levels of interactivity, however, involve more than response to the user’s orders; the level and quality of these responses makes a big difference. The pre-Java Web provided a great deal of user selectivity through hypertext links, but its level of interactivity was fairly low. Gateway (Common Gateway Interface, or CGI) programming provides a higher degree of interactivity by making it possible to customize responses to users. Gateway programs are not continuously active, however, because they require the user to click an input button before the user’s selections can be processed and a response can be sent.

    Java raises the interactive quality of the Web by making possible immediate and continuous stimuli to the user. At the same time, a Java applet can continuously accept and process input from the user. Java can also respond to this direct input and respond with customized feedback. Thus, the Web has become richly interactive with the advent of the Java age.



    Interactive Games

    Games are a popular application for programmers to create. Games naturally fit into the give-and-take flow that Java applets make possible. Games fit well into the tireless, continuous looping possible in a Java program. The game applets described in this chapter are among the earliest Java applets, yet they display the interactivity Java can bring to Web pages.

    Hang Duke

    Patrick Chan at Sun Microsystems developed an applet called Hang Duke; the applet has been distributed with the Java browser as a demonstration. Figure 5.1 shows Duke, the mascot of Java. Notice that the user couldn’t guess the word; consequently, Duke is in an advanced hanging stage.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 5.1.





    The Hang Duke game. The applet accepts input from the keyboard and displays correct letters in the appropriate slots in the word; each incorrect letter appears near the top of the gallows, and for each wrong letter, another part of Duke’s form is drawn.

    The Hang Duke applet demonstrates how the simple metaphor of pencil-and-paper game translates easily to the Web with Java.

    Hang Duke is a runnable applet. A key part of its source code accepts letters from the user through a method that detects key presses:

    public void keyDown(int keyPressed)The parameter keyPressed is an integer representing a character. This code can be changed to a character and placed in a string expression by casting, like this: (char)keyPressed.

    3-D Tennis

    Eiji Ito has created a simulation of tennis using a Java applet. By using your mouse to move your “racket” in a three-dimensional representation of a room, you can play tennis by blocking a ball. This applet is at <A href="http://www.sfc.keio.ac.jp/~t93034ei/ja1.html"">http://www.sfc.keio.ac.jp/~t93034ei/ja1.html.

    Figure 5.2 shows the tennis game in action. The bar at the right keeps track of the times that the player misses the ball, growing smaller until the game is over.

    <A href="file:///G:/Java%20Unleashed/049-5g/05/05jun02.gif">[img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 5.2.





    3-D Tennis implemented in Java. <A id=I17 name=I17>Educational Applications

    The Java <A id=I18 name=I18><A id=I19 name=I19><A id=I20 name=I20>game applets described so far in this chapter are innovative in that they use Java technology to enable users to interact with Web pages. This interactivity can also be put to a more exciting use: education. Educators have been adopting the Web for several years now for course support webs, information about their schools, and even instructional modules. However, the Web’s static text, its relatively low level of interactivity, and its limited capabilities for multimedia, have made it useful for information delivery but not as amenable to creating truly innovative, engaging applications. This section highlights some early Java applications that highlight its potential for education.

    Fractal Figures

    Fractals<A id=I21 name=I21><A id=I22 name=I22><A id=I23 name=I23><A id=I24 name=I24> are geometric shapes whose individual parts resemble the whole shape. Fractals can be generated by starting from a basic shape, and then changing the shape based on patterns echoing the structure of the overall shape. Snowflakes are like fractals: their forms at the lowest level of detail reflect a crystalline pattern similar to the whole shape. Because fractals are so hard to explain in words, what a better candidate for a Java application?<A id=I25 name=I25>

    Jim Graham at Sun Microsystems has created a Java applet that shows an algorithm that generates a fractal. (Check out <A href="http://java.sun.com/applets/applets/fractal/index.html">http://java.sun.com/applets/applets/fractal/index.html.) Figures 5.3, 5.4, and 5.5 show this applet. The first panel displays a rendering of a snowflake curve. Starting from a simple peaked line (see Figure 5.3), more peaks are added on the line segments until the entire curve resembles the ragged, yet precisely intricate snowflake shape (progressing through Figure 5.4 and Figure 5.5).

    Similarly, the last fractal shown in Figures 5.3 to 5.5 is called a Hilbert curve. Starting with a set of lines forming a Y, the algorithm adds detail until the entire fractal appears similar to a fine oriental rug—a pattern like a maze formed from a precise algorithm.

  5. #20
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 6

    Java distributes content

    Because Java is designed for distributing executable content, all Java applets, except those on the user’s local host, are distributed across networks. However, Java’s power as a language for expressing executable content involves more than the distribution of applets. Java also makes the following possible:

    • Protocol handlers that communicate to a Java-enabled browser how to handle a new method of processing information.
    • Content handlers that give a Java-enabled browser the capability to interpret new data formats.
    • Java language statements to access network resources. This enables Java programs to retrieve resources in a user’s Java-enabled browser.
    This chapter examines these capabilities in detail, showing examples and key Java statements that make these features possible. Later parts of this book will guide you through more details of Java programming. In particular, the java.net package is covered in Chapter 28, and protocol and content handlers are covered in Chapters 30 and 31.

    http://The Significance of Network D... and Retrieval

    Chapter 4 showed an applet (Magic) that allowed you to draw on images (refer to Figure 4.6). The network relationships involved in this simple applet are fairly significant. Figure 6.1 shows the connections among the content distribution, network retrieval, and display involved in this applet.

    The figure shows the network retrieval taking place:

    • The Web server www.rpi.edu sends the hypertext file marker.html to the user’s HotJava browser.
    • The IMG and APPLET elements in the file marker.html cause the HotJava browser to request an image from the Web server www.paris.org and an applet from www.rosebud.com.
    • The resulting image, applet, and hypertext page are assembled in the user’s HotJava browser. The applet executes on the user’s computer.
    This network interaction involves three Web servers and the user’s computer, besides the routers involved with the Internet network connections that relay the information from two continents. This intermingling of content demonstrates the integration Java can help accomplish. As a Web client, a Java-enabled browser is already an information integrator for many protocols. Combined with capabilities to distribute and retrieve content, Java adds another dimension to information retrieval and integration.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 6.1.



    Summary of information transfer in Magic applet demonstration.

    Handling New Protocols and Formats

    The most significant feature of a Java-enabled browser is that it is not fixed. Instead of relying on a built-in set of code for handling information delivery protocols and a fixed set of helper applications to handle media formats, a Java-enabled browser is set up so that it can adjust to learn new protocols and media formats.

    This capability significantly changes the Web:

    • Developers no longer have to rely on just the fixed set of protocols.
    • Java-enabled browsers can respond to new protocols. These protocols may support new applications or may be new kinds of protocols for information transfer.
    Retrieving and Sharing Network Information

    The protocol and content handlers can expand what a Java-enabled browser can interpret and display, opening the Web for delivery of diverse information. Java also has the capability to enrich how browsers retrieve information, giving Java programmers the chance to make applets to retrieve network information.

    Surf-o-matic

    Patrick Chan, writing about his Surf-o-matic demonstration program at http://java.sun.com/applets/applets/autopilot/index.html, calls it “almost as good as watching TV!” Surf-o-matic is a Web tour guide that can “take over” a user’s browser and change the pages. This type of tour has great potential for advertising, education, and other applications.

    Surf-o-matic is a Java applet that uses a set of classes to implement the Surf-o-matic Control Panel (see Figure 6.2). This control panel enables you to cruise the Web based on some lists of “random” URLs. First, you select which list or lists of URLs you want to surf. Then click on the Go button on the panel, and Surf-o-matic takes over your browser. Surf-o-matic switches the page every 20 seconds (or a time interval you can set) to a new page from the random lists you’ve chosen. For example, Yahoo’s (http://www.yahoo.com/) random list of Web pages is very large and is used in the example in Figure 6.2.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 6.2.



    Surf-o-matic in action.

    Figure 6.2 shows Surf-o-matic as it is retrieving a new page. Even in its present form, it is a useful standalone application. One use is as a kiosk application to demonstrate the content of the Web.

    Surf-o-matic is based on Matthew Gray’s Web Autopilot, which uses the Netscape browser’s client-pull feature. However, a HotJava browser can use Java code to implement this same type of task; it then does not have to revert to a client-pull technique. Patrick Chan’s demonstration in Surf-o-matic is a quick example showing this flexibility of Java for network information retrieval.

    JavaScript

    JavaScript (described in detail in part IX of this book) is another programming language that you can use in conjunction with Java to distribute executable content over the Web. JavaScript is different from Java. Rather than interpreting Java bytecodes in a separate file, JavaScript is written into an HTML document and is interpreted by a Netscape Web browser.

    Many companies have endorsed JavaScript as an open standard for scripting. Using JavaScript, a programmer can detect and act upon many user navigation actions, such as button-clicking, mouse position, and so on. Figure 6.3 shows an example of JavaScript in action. This simple calculator operates using HTML forms elements. However, its processing isn’t accomplished using Common Gateway Interface (CGI) programming. Instead, a JavaScript program gives the user the answer to the calculation. This shift changes the site of computation from the information provider’s server to the user’s client and host.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 6.3.



    JavaScript in action.

    A Java Graffiti Board

    Dan Guinan developed a Java Graffiti Chalkboard that demonstrates sharing information using a Java applet. This applet is located at http://www.tisinc.com/beta/chalkboard.html.

    Through the applet, the user can manipulate tools such as chalk and an eraser to draw on the board; the resulting drawing is shared among users. Figure 6.4 shows a sample board.

    Developer Dan Guinan explains that the Java Grafitti Chalkboard applet relies on a socket- based server to load and save chalkboard data. This server resides on the same machine as the Web server and communicates with the Java applet directly. The result is a “networked” applet that not only provides animation and interaction with the user but network communication as well.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 6.4.



    The Java Graffitti Board.

    Summary

    Java not only changes what can happen on a Web page, it also changes what can be retrieved and displayed on a Web page. Special handlers for new protocols and content extend what a Java-enabled browser can find and interpret. Java enables network information retrieval within applets, making it possible for an applet to “take over” a user’s display and exhibit a series of network resources or provide a way for users to share information across a network.

  6. #21
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 7

    Putting together your toolkit

    One of the most difficult aspects of learning and using Java is sorting out what the different applications of Java can do for you. There has and will continue to be much hype surrounding Java that can easily result in confusion as to what each new Java licensee brings to the table. Not only is Java quickly gaining acceptance as a programming standard, it is also spawning a new generation of development tools.

    In this chapter, you learn about the various ways Java is being used in both new and existing products, including browsers and development tools. The goal is to provide you with a broad perspective on the Java development world so you can be more informed when deciding how to put together your own Java development toolkit. You will also learn about some of the most popular online resources for keeping up with the fast-moving animal known as Java.

    Overview of Java Tools

    The list of companies that have jumped up and pledged allegiance to Java is growing at a surprising rate. With the Java bandwagon steadily rolling along, it is somewhat difficult to see how and where Java fits into many of the products that promise Java support. This is especially true when it comes to Java development tools. The products and tools important to Java development can be broken down into three categories, which follow:

    • Browsers
    • Development Environments
    • Programming Libraries
    This chapter focuses on each of these categories and discusses the Java Developer’s Kit and online sources of Java development information. Keep in mind that Java is still a growing technology, so many of the development tools are still in their infancy. Some haven’t even reached the prototype stage, whereas a few others are ready for prime time. It’s important for you to plan your Java development around what tools are available and what tools are on the horizon.

    Browsers

    The first category of Java applications to affect Java development is that of Web browsers. Without Java-compatible browsers, Java applets wouldn’t be very useful. Java browsers practically serve as the operating system for Java programs. For this reason, Java is highly dependent on the availability and success of Java browsers. Fortunately, all the major players in the browser market have signed on to Java and promised to support it. Following is a list of major companies with Web browser products that have promised some support for Java either presently or in the near future:

    Netscape

    Sun

    Microsoft

    Spyglass

    A quick overview of each of the major players and its connection to Java is presented in the following sections.

    Netscape Navigator

    The biggest player in the Web browser world, Netscape, is at the front of the Java support line. Netscape has already delivered a commercial browser with complete support for Java: Netscape Navigator 2.0. With the lion’s share of the Web browser market prior to this release, Netscape Navigator alone will secure Java among Web users and developers alike.

    Netscape has gone a step further than just supporting the Java language and run-time system. They also helped develop JavaScript, which is an object-based scripting language based on Java. The aim of JavaScript is to allow the rapid development of distributed client-server applications. However, the practical uses of JavaScript will no doubt expand as it gains acceptance. If you want to learn more about JavaScript, you’re in luck; Part IX of this book, “JavaScript,” is devoted entirely to JavaScript programming. If you want more information on Netscape Navigator itself, just sit tight because the next chapter is all about Netscape Navigator.

    HotJava

    The HotJava Web browser is Sun’s contender in the browser market. Originally designed as an experiment in Java browser development, HotJava has become a powerful model for what the future holds for Web browsers. It isn’t clear yet whether HotJava will end up being a serious competitor in the browser market, but there is no arguing its appeal to Java developers. Implemented entirely in Java itself, HotJava will no doubt be the most Java-compatible browser around. Regardless of whether HotJava catches on as a professional Web browser, it still serves as a very useful test bed for Java programmers.

    Although it is still in an early alpha stage, HotJava already surpasses other browsers in terms of extensibility. HotJava is capable of dynamically handling and interacting with new object types and Internet protocols. This is the kind of extensibility that will be required of Web browsers in the already seriously muddied waters of the Internet. Sun has promised a commercial release of HotJava in the near future. For more details about HotJava, check out Chapter 9, “HotJava.”

    Microsoft Internet Explorer

    You didn’t seriously think Microsoft would sit idly by while Java soaked up so much press attention! Of course not. After some delay, Microsoft finally agreed to license the Java technology. It isn’t clear yet exactly what technologies Microsoft plans to integrate Java into. It’s safe to say that Microsoft’s Internet Explorer Web browser will probably be the first Microsoft product to support Java. Considering the fact that Internet Explorer is tightly linked to Windows 95, it has the potential to gain a significant share of the Web browser market.

    As of this writing, there is no tentative date for when a Java-compatible version of Internet Explorer will be available. Because Netscape has already beat them to the punch, you can probably expect Microsoft to get Internet Explorer up to speed with Java pretty rapidly.

    Spyglass Mosaic

    Spyglass Mosaic is another popular Web browser that has announced future support for Java. Like Microsoft, Spyglass has given no solid dates of when their Mosaic browser might be available with Java support. Again, with all of the different browsers battling head-to-head over supporting new technologies, you can probably expect a Java-compatible version of Mosaic very soon.

    The Java Developer’s Kit

    The Java Developer’s Kit (JDK) provides the core tools and information necessary for developing programs in Java. The JDK is the first thing you should take into consideration when putting together your own Java development toolkit. Although third-party add-ons and development environments promise to make Java development smoother and easier, the JDK provides all the essential tools and information necessary to write professional Java applets immediately. Also, the JDK is Sun’s official development kit for Java, which means you can always count on it providing the most extensive Java support.

    The JDK includes a Java runtime interpreter, a compiler, a debugger, lots of applet demos, and the complete Java API source code, along with a few other useful tools. For more information on the JDK, check out Chapter 10, “The Java Developer’s Kit.”

    Development Environments

    Currently, the most uncharted region of Java programming is that of development environments. In a time when developers have become spoiled with graphical drag-and-drop programming tools, everyone expects the same out of a Java development environment. Indeed, they are on their way, but Java is still very new.

    Most of the big players in the programming-tool business have announced some type of development environment for Java. Some of this Java support will arrive in the form of add-ons for existing products, while others will be entirely new products. It’s interesting to note that a few of the development environments are themselves being developed in Java, which means that they will be available for all of the platforms that support Java. All the Java development environments are covered in more detail in Chapter 11, “Other Tools and Environments.”

    Symantec Espresso

    Symantec is the biggest PC-development tool player to have a Java development environment ready for testing. Symantec Espresso is an add-on for their Symantec C++ development system for Windows 95/NT that enables you to use the C++ facilities for Java development. Espresso features a project management system, a powerful editor, and browser tools. Symantec Espresso is already available and is a free add-on for users of Symantec C++.

    Borland Latte

    Borland, the developer of the popular Borland C++ and Delphi Windows development environments, was an early supporter of Java. Unlike Symantec, Borland has opted to develop an entirely new product for Java developers. Borland is developing their Java development environment, currently named Latte, completely in Java. This will enable them to break out of the PC market and sell Latte to Java developers on all Java-supported platforms.

    Borland has stated that Latte will be highly derived from their successful Delphi product, which is a graphical development environment for Windows 95 that is based on object-oriented Pascal. An early version of the Latte Java debugger has been released, and holds a lot of promise coming from one of the strongest PC-development tool companies.

    Microsoft Visual C++

    Although there have been no formal announcements, it is very likely that Microsoft is busily working on their own Java development environment. Microsoft is committed to creating powerful development tools, and Java is no exception. In the meantime, the Visual C++ environment for Windows 95/NT is actually fairly well suited as-is for Java development. Chapter 11, “Other Tools and Environments,” contains information on how to configure Visual C++ to work with Java.

  7. #22
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    JavaMaker

    JavaMaker is a simple development environment—developed by Heechang Choi—that runs under Windows 95 and Windows NT. It doesn’t have too many bells and whistles, but it does manage to put a front-end on the JDK. JavaMaker (currently still in beta) comes with a multiple document interface text editor and interfaces directly with the Java compiler and applet viewer. If you want to keep things simple, JavaMaker is a very useful application—even in its current prerelease state.

    Natural Intelligence’s Roaster

    If you are a Macintosh user, you’re probably thinking this discussion of development environments is skewed toward Windows. Not so! Natural Intelligence, the company that makes the popular Macintosh script editor Quick Code Pro, has released a Macintosh Java development environment. Natural Intelligence’s Java Applet Development Kit, Roaster, provides an integrated development environment with a built-in class disassembler, debugger, and compiler. It is currently available for Power Macintosh, with a 68000 version expected soon.

    Metrowerk’s CodeWarrior

    Lest you believe there is only one option for Macintosh Java programmers, Metrowerks has announced development of a Java environment based on their popular CodeWarrior C++ development environment. The Java environment, which is code-named Wired, is described by Metrowerks as a suite of Macintosh Java development tools. Metrowerks anticipates a first developer’s release of their Java tools in the summer of 1996.

    Silicon Graphic’s Cosmo

    Silicon Graphics has entered the Java foray in big way with its Cosmo development tools suite. The Cosmo technologies are aimed at providing more extensive multimedia and 3D graphics support to the Web. A core component of Cosmo is Cosmo Code, which is a Java development environment that promises to deliver a staggering array of features. Cosmo Code includes a runtime interpreter, compiler, graphical debugger, visual browser, and the Cosmo Motion and Cosmo MediaBase libraries. The core components of the Cosmo Code development kit are already available in beta form for Irix systems.

    Programming Libraries

    Because Java is object oriented, it is hard to overlook the potential for reusing Java objects. There is already a surprisingly large amount of Java classes available for free; most of which include source code. Additionally, a few commercial Java object libraries are appearing that show a lot of promise.

    Even though the commercial Java tools market is still in an embryonic state, one company in particular looks poised to provide some very interesting and powerful class libraries: Dimension X. Dimension X currently has three Java class libraries nearing release: Ice, Liquid Reality, and JACK. Ice is a 3D graphics rendering package written in Java. Liquid Reality is a VRML toolkit, based on Ice, for creating and viewing 3D worlds on the Web. Finally, JACK (Java Animation Creation Kit) is a tool for creating Java animation applets through a simple drag-and-drop interface. For more information on VRML and Dimension X, see Chapter 34, “VRML and Java.”

    Online Resources

    In the dynamic world of Java programming, nothing is perhaps more valuable than the Java Web sites. The various Java Web sites scattered around provide the latest breaking Java news and most recent releases of Java tools, not to mention a vast repository of educational material.

    Sun’s Java Site

    The official Java site on the Web is maintained by Sun and contains all the latest Java information and tools produced by Sun. You’ll definitely want to keep an eye on this site as it is the central location for obtaining Java updates. It also has a pretty extensive set of online documentation, including a really cool Java tutorial. The URL for the Sun Java site follows:

    http://www.javasoft.com/Figure 7.1 shows what Sun’s Java Web site looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 7.1.



    Sun's Java Web site.

    Gamelan

    Look no further than Gamelan for the end-all Java resource directory! With the possible exception of the official Java Web site at Sun, Gamelan is by far the most useful and comprehensive source of Java information anywhere. It has Java conveniently divided up into different categories, with each leading to a wealth of information and sample applets. Check out Gamelan yourself and you’ll see what I mean. Its URL follows:

    http://www.gamelan.com/Figure 7.2 shows what the Gamelan Web site looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 7.2.



    The Gamelan Web site.

    SunWorld Online

    SunWorld Online is an online journal published by IDG Communications that often contains useful information that relates to Java. It has a regular column called “Java Developer” that usually tackles an interesting topic related to Java programming. SunWorld Online is located at the following URL:

    http://www.sun.com/sunworldonline/Figure 7.3 shows what an issue of SunWorld Online looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 7.3.



    The Sun World Online Web site.

    Digital Espresso

    Digital Espresso is an online weekly summary of the traffic appearing in the various Java mailing lists and newsgroups. Digital Espresso is an excellent Java resource because it pulls information from a variety of sources into a single Web site. Following is the URL for Digital Espresso:

    http://www.io.org/~mentor/phpl.cgi?J___Notes.htmlFigure 7.4 shows what the Digital Espresso Web site looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 7.4.



    The Digital Espresso Web site.

    Summary

    You learned in this chapter that putting together a Java toolkit isn’t as easy as going out and buying a development environment. Because Java is such a new technology, many of the development options for developers have yet to mature into solid applications. At this stage, it’s important to know what is available and what is being promised in the future.

    You also learned about the different Java-compatible Web browsers and development environments that are in the works, along with a few that are available now. You then learned about the Java Developer’s Kit and some class libraries that have the potential to raise the ante on Java development. Finally, some online resources for keeping up-to-date with Java were discussed.

    Because Java-supported browsers are so important to Java developers, the next chapter focuses on what will possibly be the most established of the Java Web browsers: Netscape Navigator.

  8. #23
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 8

    Netscape

    Netscape is without a doubt the largest player in the Web browser business. It is insanely popular Netscape Navigator Web browser dwarfs all other browsers in terms of market share, with no signs of any significant losses in the near future. It is certainly going to see some fierce competition, but Netscape is staying on top of things and integrating the latest technology into Netscape Navigator.

    Java currently is the most important of these new technologies. With the advent of Navigator 2.0, Netscape has provided complete support for the Java language. Additionally, Netscape has collaborated with Sun to create a scripting language based on Java called JavaScript. Together, these two technologies promise to keep Netscape firmly rooted as the king of the Web browser hill. For Web developers, this means that interactivity on the Web has finally comeof age.

    NOTEAs of this writing, the Macintosh and Windows 3.1 versions of Netscape Navigator still do not have support for Java. However, you can expect support to arrive for these platforms in the near future.

    In this chapter, you learn about how Java and JavaScript impact Netscape’s new product line, especially the Navigator Web browser. Netscape Navigator 2.0 provides very strong support for Java and JavaScript, as you’ll see.

    Netscape Products

    Before getting into the Java-specific aspects of the latest release of Netscape Navigator, it’s important to bring you up to date with this version of the popular Web browser, along with other Web-related products being offered by Netscape. First, Netscape has opted for two different versions of Navigator, standard and gold. Navigator 2.0 is the logical upgrade to the original Navigator Web browser. Navigator Gold 2.0 includes Navigator 2.0, along with a Web development environment, enabling users to edit HTML files graphically.

    Additionally, Netscape is releasing Live Wire, which is a Web development environment that provides the tools necessary to create and manage Web sites. Live Wire includes Navigator Gold and the JavaScript scripting language. And if Live Wire isn’t enough for you, Netscape also has Live Wire Pro, which adds to Live Wire the capability to browse, search, and update relational databases.

    To summarize, Netscape is offering the following Java-supported products to the Webcommunity:

    Navigator 2.0

    Navigator Gold 2.0

    Live Wire

    Live Wire Pro

    Netscape’s new Web tools will no doubt set the standard for others to follow. With its new features and wide support for new technologies, Navigator 2.0 should easily match the popularity of its predecessor. However, as impressive as the new Navigator browser appears to be, Netscape may ultimately gain more from the release of Navigator Gold and Live Wire. The early integration of Java into all of these products has set the stage to bring Java to the Web in full force.

    Navigator 2.0

    Navigator 2.0 is the first major upgrade to the immensely popular Netscape Navigator Web browser. This upgrade includes improved e-mail, newsgroup, FTP, and navigation capabilities, along with inline multimedia plug-ins. The inline multimedia plug-ins include support for Adobe Acrobat PDF documents and Macromedia Director presentations, among others. The Navigator plug-in supporting Macromedia Director presentations is called Shockwave. Additionally, a plug-in supporting Apple’s QuickTime multimedia standard is expected soon. Navigator 2.0 is also the first browser to provide complete Java support. Figure 8.1 shows what Netscape Navigator 2.0 looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 8.1.





    Netscape Navigator 2.0. The new Navigator update also adds enhanced performance through client-side image maps, progressive JPEG images, and streaming audio and video. Its new security features include digital ID, secure courier for financial transactions, and secure e-mail and news. Navigator 2.0 also features advanced layout capabilities, including frames, which enable the display of multiple, independently scrollable panels on a single screen. Each of these panels can have a different Web address as its source.

    Navigator Gold 2.0

    Navigator Gold 2.0 is a tool built around Navigator 2.0 that enables Web developers to design and edit HTML documents graphically. The HTML editor is integrated into the Navigator environment, and effectively combines editing and viewing functions into one application. It will be interesting to see how Navigator Gold is perceived by the Web development community, as it is really the first attempt by a major Web player at providing a graphical HTML development system.

    Live Wire and Live Wire Pro

    Netscape’s Live Wire goes a step beyond Navigator Gold by providing an environment that lets developers graphically build and manage applications and multimedia content for the Internet. Live Wire’s graphical design approach is aimed at simplifying the management of complex Web document hyperlinks. Live Wire includes Navigator Gold and the JavaScript scripting language. Netscape is also offering Live Wire Pro, which adds database connectivity to Live Wire. With Live Wire Pro, users can interact with relational databases on the Web.

    Netscape Support for Java

    Netscape Navigator 2.0 is the first major Web browser to provide support for Java. Although this aspect of Navigator has generated a significant amount of press attention, it’s important to realize that the bulk of Navigator’s Java support takes place behind the scenes. Many Navigator users will likely see Web pages come to life and not fully realize that Java is the technology making it all happen. The point is that the Java support in Navigator affects the content of Web pages viewed in Navigator a great deal, but affects the Navigator interface and options very little.

    Because the Java support in Navigator is a behind-the-scenes issue, it isn’t always clear what parts of a Web page are using Java. If you saw a Java Web page and didn’t know anything about Java, you might just think that Web page developers were pulling off neat tricks with CGI or some other scripting language. But you are well on your way to becoming a Java expert, so you know better; Java opens the door to doing things that are impossible with scripting languages like CGI.

    Java programs appear in Navigator as applets that are embedded in Web pages. Java applets are referenced in HTML source code using a special APPLET tag. Navigator parses these tags and automatically launches an internal Java interpreter that executes the Java applets. By implementing a Java runtime interpreter, Navigator provides the layer of functionality that allows all Java applets to run. Beyond this, there isn’t really anything particularly special about the way Navigator supports embedded Java applets. This simply means that the only significant component in Navigator necessary to support Java is the integrated Java runtime interpreter.

    Other than seeing functionality in Web pages that you’ve never seen before, there’s not much in Navigator to inform you that a Java applet is running. A few small things you might notice are the various messages that appear in the Navigator status bar when an applet is preparing to run. You may also notice a significant delay while Java applets are being transferred to your machine, especially those that use a lot of graphics and sound.

    Another Java-specific feature of Navigator is located under the Options menu. The Show Java Console menu command causes Navigator to open a Java Output console window. The output window displays output generated by currently running Java applets. Figure 8.2 shows what the Navigator Java Output window looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 8.2.





    The Netscape Navigator Java Output window. Configuring Java with Netscape

    When you first install Netscape Navigator, Java support is automatically installed and enabled by default. Remember, the Java support in Navigator is built-in, so you don’t have to do anything special to get it working. As a result, you can immediately start viewing and interacting with Java-enhanced Web sites.

    The only real Java-specific option in Navigator is whether or not you want Java support enabled. Most of the time you will want to leave Java support enabled, so that you can enjoy the benefits of the Java technology. However, if you are experiencing problems with Java or with a particular Java Web site, you can disable Navigator Java support. To do this, select the Security Preferences command from the Navigator Options menu. The Disable Java checkbox is used to enable/disable Java support. Figure 8.3 shows the Navigator Security Preferences dialog box.

    If Java is disabled, you will still be able to view Java-enhanced Web sites, you just won’t be able to view or interact with the Java applets contained within them.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 8.3.





    The Netscape Navigator Security Preferences dialogue box. Java Applets

    There are already many Java applets available for you to run and try out, ranging from games to educational instruction. Most of them come with source code, so you can use them as references for your own Java programs. Figure 8.4 shows a crossword puzzle Java applet running in Netscape Navigator.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 8.4.





    A crossword puzzle Java applet running in Netscape Navigator. The different applications for Java are limitless. Figure 8.5 shows a very interesting application of Java: an instructional dance applet.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 8.5.





    An instructional dance Java applet running in Netscape Navigator. If you want to check out some of the Java applet demos, take a look at the Java Applet Demos Web page on Netscape’s Web site, which is shown in Figure 8.6:

    http://www.netscape.com/comprod/products/navigator/version_2.0/java_applets/[img]file:///G:/Java%20Unleashed/figicon.gif[/img] FIGURE 8.6.





    Netcape's Java Applet Demos Web site. If you want to find out more about creating your own Java applets that can be integrated into Web pages, check out Part V of this book, “Applet Programming.”

    JavaScript

    JavaScript is a scripting language described by Netscape as a lightweight version of Java. JavaScript promises to enable less technical Web users and developers the capability to create interactive content for the Web. You can think of JavaScript as a higher level complement to Java. Netscape Navigator supports JavaScript by providing an internal JavaScript interpreter.

    JavaScript was designed with the goal of creating a simple and easy-to-use cross-platform scripting language that could connect objects and resources from both HTML and Java. While Java applets are primarily developed by programmers, JavaScript is intended to be used by HTML document authors to dynamically control the interaction and behavior of Web pages. JavaScript is unique in that is has been designed to be complementary to both HTML and Java.

    If you can believe it, JavaScript is actually an even newer technology than Java. Because JavaScript was developed jointly by Sun and Netscape, it is almost guaranteed to be widely adopted by the Web community. However, it may still take some time before you see truly compelling applications of JavaScript. Part IX of this book, “JavaScript,” is entirely devoted to understanding and using JavaScript.

    Summary

    The latest release of Netscape’s line of Web products promises to further establish Netscape as the premier Web tool provider. A central technology present in these tools is Java, which brings interactivity to the Web. Netscape Navigator, along with already being the most popular Web browser available, is the first major Web browser to fully support Java.

    In this chapter, you learned about the different tools available from Netscape and how Java relates to them. You also learned about JavaScript, and how it is positioned to provide a higher level option to HTML developers wishing to add interactivity without learning Java inside and out. Netscape’s early support for both Java and JavaScript is a sure sign that these technologies are here to stay.

    Now that you have an idea about how the most popular Web browser supports Java, you may be interested in learning about a new browser developed by the creators of Java, Sun Microsystems. The next chapter takes a close look at HotJava, Sun’s new Web browser that is tightly integrated with Java.

  9. #24
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 9

    HotJava

    Java applets are only as useful as the Web browsers that support them. Although Netscape Navigator is certainly a strong contender for the Java support crown, Sun has its own browser that is specifically designed with Java in mind: HotJava. The HotJava Web browser builds on the techniques established by NCSA Mosaic and Netscape Navigator, while adding the capability to add new behaviors dynamically. The tight link to the Java language is what enables HotJava to have this dynamic behavior.

    In this chapter, you learn all about HotJava, including its major features and how to install and use it. Although HotJava as a software product is still in the development stages, it is readily available and quite usable in its current alpha form. This chapter explores the primary features of HotJava and how they impact Web navigation and the Java language.

    This Is HotJava

    Before getting into the specifics of how to install and use HotJava, it’s important to take a look at why HotJava is important. Actually, if you first want to literally take a look at HotJava, check out Figure 9.1.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.1.



    The HotJava Web browser.

    Figure 9.1 shows what HotJava looks like. You’ll learn about how to use HotJava a little later in this chapter. For now, it’s important to understand why HotJava is significant as a Web browser. There are a variety of technical innovations in HotJava that promise to make it more extensible than other Web browsers. These innovations stem largely from the fact that HotJava is designed around supporting the Java language.

    The primary innovation that sets HotJava apart from other browsers is its extensibility. Where other browsers have most or all of their components hardwired to the executable browser application, HotJava opts for a more distributed approach. This means that by itself, HotJava doesn’t really support any object types or Internet protocols. But its extensible design provides a very open path to add support without modifying the HotJava application itself. Furthermore, HotJava can be extended to provide new support automatically and on demand without the user even having to know.

    Following is a list of the major features in HotJava:

    • Dynamic Object Types
    • Dynamic Protocols
    • Network Security
    Dynamic Object Types

    Along with dynamic content within Web pages, HotJava also aims to be dynamic on a few other fronts. One of these fronts is the support for dynamic object types. An object type refers basically to a file format, such as the popular GIF (Graphics Interchange Format) graphics files. Although most Web browsers provide support for the most popular object types right now, who’s to say what new object types will appear in the future? Obviously no one knows what object types will become popular in the future. For this reason, HotJava takes an open-ended approach to supporting object types. HotJava is capable of dynamically linking to Java code for handling a particular object type on the fly. Rather than Sun having to create a new version of HotJava each time a new object type appears on the scene, HotJava can instead locate an object handler and deal with it dynamically. Incidentally, object handlers are also known as content handlers. Figure 9.2 shows the difference between HotJava’s dynamic connection to objects and a conventional Web browser’s built-in support for objects.

    Notice in the figure that both approaches provide similar support for object types that are currently popular. The difference arises when new types are introduced; HotJava transparently attaches to the handlers for new object types, whereas other browsers must implement handlers internally.

    You may be wondering where the object handlers come from, and how HotJava knows about them to begin with. Typically, the vendor that creates an object will also create a handler routine for interpreting the object. As long as the handler is present on a server with the objects in question, HotJava can link to the code and automatically upgrade itself to support the new object type. While other Web browser developers are busily hacking in patches to support new object types, HotJava users will be automatically and transparently upgrading each time they encounter a new object type.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.2.



    How HotJava and conventional Web browsers differ in their handling of objects .

    Dynamic Protocols

    Similar to its dynamic support for new object types, HotJava also takes a dynamic approach to handling new Internet protocols. The most important components of the Internet are the protocols used for each medium of communication, such as HTTP or FTP. Think back to the days before the HTTP protocol and you’ll realize what I mean! As with objects, there is no way to foresee what new Internet protocols will spring up in the future. The best way to handle this unknown is to anticipate a certain flux in protocol growth and write applications that can adapt to change. Sun did exactly this by designing HotJava so that it could dynamically link in support for new protocols.

    You are probably familiar with Internet URLs, which define the location of Internet resources. An example URL follows:

    http://www.javasoft.com/This URL is for Sun’s Java home page. As you can see, the protocol type for this URL is specified at the beginning of the URL name. In this case, the protocol type is specified as http, which stands for hypertext transfer protocol. Most Web browsers have built-in functionality to handle protocols such as HTTP. HotJava, on the other hand, looks externally to handle different protocols. When HotJava encounters a URL, it uses the protocol name to determine which protocol handler to use to find a document. Like a handler for an object, a protocol handler is a separate piece of code that defines how to interpret information from a particular protocol. Figure 9.3 shows the difference between how HotJava and conventional browsers manage protocols.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.3.



    How HotJava and conventional Web browsers differ in their handling of protocols.

    You may have noticed that Figure 9.3 looks very similar to Figure 9.2. Indeed, HotJava’s support for new protocols parallels its support for new object types. The same approach of forcing outside handlers to provide the specific implementations for new objects works equally well when dealing with new protocols.

    Network Security

    When you start thinking about interactive content and what it means to the broad base of users it will affect, there is an unavoidable issue of security. To get an idea of how important the issue of security is, think back to how things were before the Web. Prior to the Web, online services, independent bulletin boards, and private networks served as the primary electronic communication mediums. Most of these mediums were and still are completely based on static content. Even so, the instances of viruses and other security-related problems have always been in relative abundance. In most of these cases, users would knowingly transfer a file to their computer that was assumed to be safe. The file would end up doing harm to their machine once it was transferred. Obviously, the users wouldn’t have transferred the file if they had known about the virus beforehand. The point is that even with users having complete control over which files are transferred, viruses have still flourished.

    Now consider the possibilities for security breaches with interactive content in the global Internet environment. Given that users are able to interact with Web pages in an interactive environment, the software must be able to respond dynamically. You’ve probably guessed that this creates a potentially dangerous situation. This brings us to the next key issue in the design of HotJava: security.

    In HotJava, you can specify security options relating to what access you want to allow incoming executable content to have to your machine. You can specify whether and how much you want to allow applets to be able to read, write, or change files on your machine. You can set up security regions in HotJava by creating firewalls. A firewall is typically a set of computers within a certain domain name. Usually these computers are assumed to be safe, so they are listed as being located behind the firewall. You’ll learn more about configuring firewalls later in this chapter.

    Java and HotJava

    The majority of the features implemented in HotJava stem from the fact that HotJava is designed around supporting Java. Before getting into more specifics regarding HotJava, it is important to clarify the relationship between Java and HotJava.

    To recap prior chapters, Java is an object-oriented programming language derived in many ways from C++. Java enables you to write programs and applets that can be embedded in Web pages and executed interactively. HotJava is a Web browser written in Java that implements object and protocol handlers as external libraries. HotJava is akin to Netscape Navigator or NCSA Mosaic, with the primary difference being that it is written in the Java language and is far more extensible.

    Java Versions

    The Java language and HotJava browser are both very new technologies that are still in the developmental stages. The first released version of the Java language was known as the alpha release. A decent number of programs were written under the alpha release and are still around. However, Sun later released a beta version of Java with some major changes to the programming interface. This resulted in a rift between programs written using the alpha release of Java and programs written using the beta release. Add to this confusion the release of a final version of Java.

    With the release of the beta version of Java, Sun declared the Java API frozen, meaning that none of the existing classes would be modified in the final release. However, this didn’t restrict Sun from adding new classes and methods to Java; it just meant they couldn’t change the old ones. This results in backward compatibility between the final and beta versions of Java; all beta programs should compile and run fine under the final release of Java.

    The remaining problem then is what to do about the alpha programs still in existence? Most developers have already ported or begun porting their alpha programs to the beta, and now, final releases. All new Java development should be focused on the final release.

    HotJava’s Support for Java

    But there’s always a catch! The problem right now is that Sun has focused its efforts on polishing Java, and has kind of dropped the ball on bringing HotJava up to date. What this means is that the alpha release of HotJava, which is the latest, only supports alpha Java applets. You can’t program to the final Java API and incorporate the applets into the current version of HotJava. Hopefully, by the time you read this Sun will be closer to releasing a beta or even final version of HotJava, but it’s still too early to guess.

    So, you may be wondering how to deal with this problem? Do you go ahead and write outdated alpha code so you can use HotJava, or do you blindly write final code and pray that a new version of HotJava that will run the final code will be released soon? The answer is neither. In light of this problem, Sun released an applet viewer program that supports the final release of Java. Additionally, Netscape Navigator 2.0 is supposed to fully support the Java final release. You’ll learn more about the applet viewer in Chapter 10, “The Java Developer’s Kit.” You can use either of these applications as a test bed for final release Java applets.

    You’re probably wondering why bother discussing HotJava when it’s currently not even useful for working with the final release of Java? The answer is that HotJava is an important technology, and all release delays aside, it will still be an important application for Web users and Java programmers in the future. Furthermore, because it is itself written in Java, it will be without a doubt the most Java-compatible browser around. In the meantime, you can still have a lot of fun with HotJava by running the many alpha Java programs that are available.

  10. #25
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Setting Up HotJava

    Installing and configuring HotJava is pretty straightforward. Before you begin installing HotJava, you may want to check and see if there is a newer release than the one you have. At the time of this writing, the latest release of HatJava was alpha release 3. This version will run alpha Java applets fine, but you may want to check directly with Sun to find out the latest version of HotJava available. Sun maintains a Web site devoted entirely to Java and HotJava. You actually saw the Java URL earlier in this chapter, but here it is again:

    http://www.javasoft.com/This is the same place where you can download the latest release of the Java Developer’s Kit (JDK). You’ll learn more about the JDK in Chapter 10. This is also the primary location for learning the latest news and support issues surrounding Java and HotJava. Figure 7.1 in Chapter 7 shows what the Java Web site at Sun looks like.

    HotJava usually comes compressed in a self-extracting archive. To install HotJava, you simply execute the archive file from the directory where you want HotJava installed. For example, if you want to install HotJava on a Windows 95 machine, you would execute the self-extracting archive file from the C:\ root directory. The archive will automatically create a HotJava directory below C:\ and build a directory structure within it to contain the rest of the support files. All the related files are automatically copied to the correct locations in the HotJava directory structure.

    NOTEThe current alpha release of HotJava only supports the Solaris and Windows 95/NT platforms. It is expected that a commercial release of HotJava will also support Macintosh and Windows 3.1, but at this point it is still speculation.Once HotJava is installed, you are ready to run it. You run HotJava by executing the program HotJava.exe, which is located in the HotJava\bin directory. You can specify a URL as a parameter to HotJava. If specified, HotJava will open the document specified by this URL rather than the default URL document. Assuming you don’t enter a URL when you start HotJava, you will be presented with the Welcome page shown in Figure 9.1 earlier. You’ll definitely want to try out some of the links on this page later. If this is the first time you’ve run HotJava, you’ll also be presented with the Security dialog box shown in Figure 9.4. Just click the Apply button for now and everything will be OK. You’ll learn more about the security options in this dialog box a little later in this chapter.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.4.

    The HotJava Security dialog box.

    HotJava uses three system environment variables to determine various options for the browser. These environment variables follow:

    • HOTJAVA_HOME
    • WWW_HOME
    • HOTJAVA_READ_PATH
    • HOTJAVA_WRITE_PATH
    The HOTJAVA_HOME variable specifies the path where HotJava looks for resources in order to run. HOTJAVA_HOME defaults to being set to the directory where HotJava was installed. The WWW_HOME variable specifies the default home page used in HotJava. This is the page HotJava attempts to load on startup. WWW_HOME defaults to being unset. If it is left unset, HotJava defaults to the URL doc:///index.html, which is the Welcome page.

    The HOTJAVA_READ_PATH variable specifies a colon-separated list of files and directories to which Java applets have read access. The default setting for HOTJAVA_READ_PATH is <hotjava-install-dir>:$HOME/public_html/. You give read access to new files and directories by adding a colon and the file or directory onto the end of the list. For example, if you wanted to give the Docs directory read access, and it was located just off of the root directory, you would set HOTJAVA_READ_PATH to the following:

    <hotjava-install-dir>:$HOME/public_html/:$HOME/Docs/Similarly, HOTJAVA_WRITE_PATH specifies a list of files and directories that Java applets have write access to. Any files or directories not explicitly given read or write permission through these variables will be inaccessible to Java applets.

    Using HotJava

    Now that you have HotJava up and running, you’re ready to learn some more about how to use it. The HotJava browser application is composed of five major parts, which follow:

    • The menu bar
    • The URL edit box
    • The client area
    • The toolbar
    • The status bar
    To see where these parts are located in HotJava, refer back to Figure 9.1, which shows the HotJava application window. The HotJava menu bar is located just below the caption bar for the application, and consists of a series of pull-down menus. You’ll learn about the specific menu commands a little later in this chapter. The URL edit box is located just below the menu bar and is used to manually enter document URLs. You’ll learn how to enter URLs in HotJava in the next section of this chapter.

    The client area of HotJava is located just below the URL edit box and extends down to the toolbar near the bottom of the application window. The client area takes up most of HotJava’s screen real estate, and is where documents are displayed. Because the client area is where documents are displayed, it is also the display area for Java applets.

    The HotJava toolbar consists of five buttons and is located just below the client area. These buttons are used to navigate through Web pages. The Left and Right Arrow buttons are used to move forward and backward through documents that you have already viewed. The Home button takes you to the default home page for HotJava. If you recall, this page is specified by the WWW_HOME environment variable. The Reload button is used to reload the current document. And finally, the Stop button is used to stop the loading of a document.

    The status bar is used to inform you of the status of operations. For example, while a document is being fetched, the status bar displays a message notifying you that it is fetching the document. The status bar also displays the names of links to documents when you drag the mouse over them.

    Working with URLs

    Document URLs are specified by entering them into the URL edit box near the top of the HotJava application window. To open a new URL document, simply type the name into the edit box and press Return. HotJava will immediately start fetching the document, which will be evident by the message displayed in the status bar.

    To stop fetching a document, just click on the Stop button. The Stop button only stops the loading of HTML pages; it does not stop or even affect any running Java applets.

    Menu Commands

    The HotJava menu commands provide access to all the functionality in HotJava. These menu commands can be grouped into five categories, which correspond to the pull-down menu names shown in the menu bar. Following are the menu command categories:

    • File
    • Options
    • Navigate
    • Goto
    • Help

  11. #26
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    File Commands

    The File menu commands consist of commands related to managing URL documents. Some commands are listed under the File menu but remain unsupported in the alpha release of HotJava. The following File menu commands are supported under the alpha 3 release of HotJava:

    • Open
    • Reload
    • View Source
    • Quit
    The Open command displays a dialog box where you can specify a document URL to open. This functionality is identical to typing a document URL in the URL edit box below the menu bar. The Reload command reloads the current document. Selecting the Reload command is exactly the same as clicking the Reload button on the toolbar. The View Source command opens up a window containing the HTML source code for the current Web page. Finally, the Quit command exits the HotJava application.

    Options Commands

    The Options menu commands are used to specify HotJava environment options. A few commands are listed under the Options menu but remain unsupported in the alpha release of HotJava. The following Options commands are supported under the alpha 3 release of HotJava:

    • Security
    • Properties
    • Flush Cache
    • Progress Monitor
    The Security command opens a dialog box where you specify the level of security to be applied to incoming executable content. This is the same dialog shown in Figure 9.4 that is displayed the first time you run HotJava. The dialog box provides the following security modes to choose from: No access, Applet host, Firewall, or Unrestricted. The No access security mode specifies that HotJava cannot load any Java applets. This is the safest, but obviously most restricted security mode. The next safest mode is Applet host, which specifies that HotJava can only run Java applets residing on the local machine. Next comes the Firewall security mode, which specifies that HotJava can only run applets from behind the firewall. Finally, the Unrestricted mode allows HotJava to load any Java applets.

    If you select the Firewall security mode, you’ll need to configure the firewall. You do this by clicking the Configure Firewall button. When you click this button, the dialog box shown in Figure 9.5 appears.

    The purpose of this dialog box is to enable you to specify which systems are located behind the firewall; that is, which systems are considered safe. You specify systems within the firewall by entering the domain or host name of the system, selecting whether it is a domain or host in the drop-down list, and then clicking the Add button. You can change or delete firewall entries by using the Change and Delete buttons. Once you are happy with the firewall settings, click Apply to accept them.

    The Properties menu command opens a dialog box which lets you change general HotJava properties. The Properties dialog box is shown in Figure 9.6.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.5.



    The HotJava Configure Firewall dialog box.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.6.



    The HotJava Properties dialog box.

    The first few properties in this dialog box enable you to specify different proxies and their associated ports. The Firewall Proxy refers to the host name and port number of a local firewall proxy server. The FTP Proxy is the host name and port number of an HTTP proxy to use for all FTP URLs. Finally, the Caching Proxy refers to the host name and port number of a caching server. If you don’t want to use any of the proxies, just leave the check boxes next to each one unchecked.

    The Properties dialog also enables you to view the read and write paths for HotJava. These are the same paths specified by the HOTJAVA_READ_PATH and HOTJAVA_WRITE_PATH environment variables. You cannot modify these variables from the Properties dialog box.

    The Underline anchors property determines whether or not HTML anchors (links) are underlined when displayed. The Delay image loading and Delay applet loading properties determine how images and applets are loaded in HotJava. If you check these options, HotJava will only load images and applets when you click on them. This is sometimes useful when you have a slow connection. If you leave these options unchecked, HotJava will load all images and applets along with the rest of an HTML page.

    The Flush Cache menu command flushes any images and audio that have been cached by HotJava. Typically HotJava will cache the most recently used images and audio to your hard drive in order to speed up loading time. You may want to use the Flush Cache command if you know a cached image or sound has changed and should be transferred again.

    The Progress Monitor menu command brings up a window with a progress monitor for seeing how much of a document has been loaded. Figure 9.7 shows what the progress monitor looks like in action.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.7.



    The HotJava Progress Monitor window.

    The progress monitor is considered an experimental tool, but is still interesting in its current form. You can watch and see the status of different objects as they are loaded.

    Navigate Commands

    The Navigate menu commands provide you with a means to navigate through documents. The commands listed under the Navigate pull-down menu that are supported under the alpha release of HotJava follow:

    • Forward
    • Back
    • Home
    • Show History
    • Add Current to Hotlist
    • Show Hotlist
    The Forward command moves to the document viewed prior to selecting the Back command or button. This means that the Forward command can only be used after you have used the Back command. The Back command moves back to the last document viewed. The Home command displays the default HotJava home page, which is specified in the WWW_HOME environment variable. All three of these commands perform the exact same functionality as their equivalent buttons on the toolbar.

    HotJava automatically maintains a history list of documents that have been viewed. The Show History command displays the history list and enables you to revisit a document in the list. Figure 9.8 shows what the HotJava History List window looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.8.



    The HotJava History List Window.

    To open a document in the history list, simply click on the document and click the Visit button. The history list is cleared each time you start HotJava.

    Along with the history list, HotJava also keeps up with a hotlist, which is a list of favorite documents. The Add Current to Hotlist command adds the currently viewed document to the hotlist. To see what documents are in the hotlist, use the Show Hotlist command. HotJava’s hotlist is very similar in function to Netscape’s bookmarks and Internet Explorer’s favorite places. When you select Show Hotlist, you’ll see the window shown in Figure 9.9.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.9.



    The HotJava Hotlist window.

    You can visit a document in the hotlist by clicking on the document and clicking the Visit button. You can also delete documents from the list using the Delete button. There is one additional feature of the hotlist that you may be curious about: a check box labeled In Goto Menu. This check box enables you to choose documents in the hotlist that will also appear as menu selections under the Goto pull-down menu.

    Goto Commands

    The Goto menu consists of a single command and multiple document links. The Goto menu is used as a list of links to the most important documents in the hotlist. You can quickly open documents in the Goto menu by selecting the document entry in the menu. The only command supported under the Goto menu is Add Current, which adds the current document to the hotlist and the Goto menu itself.

    Help Commands

    The Help menu consists of a variety of links to useful HTML documents, along with one command. Each document link is pretty self-explanatory, so you can explore them on your own. The only command on the Help menu is the Search HotJava Documentation command. This command enables you to search the HotJava documentation for a particular topic. Figure 9.10 shows what the documentation search dialog box looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 9.10.



    The HotJava documentation search dialog box.

    To search on a topic, just type the topic in the query edit box and click the Search button. Documents found matching the topic are listed in the list box. To go to one of the matching documents, just click on it in the list box.

    Status Icons

    HotJava provides visual status indicators when it is loading document information. These indicators, or icons, are displayed in place of the object they are loading until the object has been successfully loaded. The different status icons supported by HotJava follow:

    • Raised gray box
    • Yellow box
    • Yellow box with arrow
    • Orange box
    • Red box
    • Red box with arrow
    The raised gray box means that an image or applet is still loading. The yellow box means that delayed image loading is in effect for an image. To load the image you must click on the icon. The yellow box with an arrow means that delayed image loading is in effect for an image and that the image is a link to another document. Clicking on the arrow opens the linked document, and clicking on any other part of the icon loads the image. The orange box is similar to the yellow box except it deals with Java applets rather than images; it specifies that delayed applet loading is in effect for an applet. To load the applet, just click on the icon.

    Both red box icons mean that an error has occurred while attempting to load an image or applet. The difference between the two is that the icon with an arrow specifies that a document link has failed to load, rather than the image or applet itself.

    Summary

    In this chapter you learned all about the HotJava Web browser and how it relates to Java. It is not clear whether Sun intends for HotJava to be a serious competitor in the Web browser market. Nevertheless, it will be the browser to watch when it comes to providing complete Java support in the future. As a result of its support for Java, HotJava has the potential to be a technologically superior Web browser through its extensible support of dynamic content, objects, and Internet protocols.

    The only downside to HotJava at this point is that it is still an unfinished product, and as a result has a versioning conflict with the latest version of Java. Nevertheless, it is only a matter of time before HotJava will be a crucial Internet technology, simply because of its tight link to the Java language.

    Now that you have HotJava pretty well figured out, it92's time to press on and learn more about Java itself. The next chapter covers the Java Developer’s Kit, which is the standard toolkit for developing Java programs.

  12. #27
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 10

    The Java developer's kit

    The Java Developer’s Kit, or JDK, is a comprehensive set of tools, utilities, documentation, and sample code for developing Java programs. Without it, you wouldn’t be able to do much with Java. This chapter focuses on the JDK and the tools and information supplied with it. Although some of the tools are discussed in more detail in later chapters, this chapter gives you a broad perspective on using the tools to develop Java programs using the JDK.

    In this chapter you learn what tools are shipped in the JDK and how they are used in a typical Java development environment. With the information presented in this chapter, you will be well on your way to delving further into Java development; the Java Developer’s Kit is the first step toward learning to program in Java.

    Getting the Latest Version

    Before you get started learning about the Java Developer’s Kit, it’s important to make sure that you have the latest version. As of this writing, the latest version of the JDK is the final release 1. This version will probably be around for a while, so you’re probably OK. Just to be sure, you can check Sun’s Java Web site to see what the latest version is. The URL for this site follows:

    http://www.javasoft.com/This Web site provides all the latest news and information regarding Java, including the latest release of the JDK. Keep in mind that Java is a new technology that is still in a state of rapid change. Be sure to keep an eye on the Java Web site for the latest information.

    The JDK usually comes as a compressed self-extracting archive file. To install the JDK, simply execute the archive file from the directory where you want the JDK installed. The archive will automatically create a java directory within the directory you extract it from, and build a directory structure to contain the rest of the JDK support files. All the related files are then copied to the correct locations in the JDK directory structure automatically.

    Overview

    The Java Developer’s Kit contains a variety of tools and Java development information. Following is a list of the main components of the JDK:

    • The Runtime Interpreter
    • The Compiler
    • The Applet Viewer
    • The Debugger
    • The Class File Disassembler
    • The Header and Stub File Generator
    • The Documentation Generator
    • Applet Demos
    • API Source Code
    The runtime interpreter is the core runtime module for the Java system. The compiler, applet viewer, debugger, class file disassembler, header and stub file generator, and documentation generator are the primary tools used by Java developers. The applet demos are interesting examples of Java applets, which all come with complete source code. And finally, if you are interested in looking under the hood of Java, the complete source code for the Java API (Application Programming Interface) classes is provided.

    The Runtime Interpreter

    The Java runtime interpreter (java) is a stand-alone version of the Java interpreter built into the HotJava browser. The runtime interpreter provides the support to run Java executable programs in compiled, bytecode format. The runtime interpreter acts as a command-line tool for running nongraphical Java programs; graphical programs require the display support of a browser. The syntax for using the runtime interpreter follows:

    java Options Classname ArgumentsThe Classname argument specifies the name of the class you want to execute. If the class resides in a package, you must fully qualify the name. For example, if you want to run a class called Roids that is located in a package called ActionGames, you would execute it in the interpreter like this:

    java ActionGames.RoidsWhen the Java interpreter executes a class, what it is really doing is executing the main method of the class. The interpreter exits when the main method and any threads created by it are finished executing. The main method accepts a list of arguments that can be used to control the program. The Arguments argument to the interpreter specifies the arguments passed into the main method. For example, if you have a Java class called TextFilter that performs some kind of filtering on a text file, you would likely pass the name of the file as an argument, like this:

    java TextFilter SomeFile.txtThe Options argument specifies options related to how the runtime interpreter executes the Java program. Following is a list of the most important runtime interpreter options:

    • -debug
    • -checksource, -cs
    • -classpath Path
    • -verbose, -v
    • -verbosegc
    • -verify
    • -verifyremote
    • -noverify
    • -DPropertyName=NewValue
    The -debug option starts the interpreter in debugging mode, which enables you to use the Java debugger (jdb) in conjunction with the interpreter. The -checksource option causes the interpreter to compare the modification dates of the source and executable class files. If the source file is more recent, the class is automatically recompiled.

    NOTEThe -checksource and -verbose options provide shorthand versions, -cs and -v. You can use these shorthand versions as a convenience to save typing.

    The Java interpreter uses an environment variable, CLASSPATH, to determine where to look for user-defined classes. The CLASSPATH variable contains a semicolon-delimited list of system paths to user-defined Java classes. Actually, most of the Java tools use the CLASSPATH variable to know where to find user-defined classes. The -classpath option informs the runtime interpreter to override CLASSPATH with the path specified by Path.

    The -verbose option causes the interpreter to print a message to standard output each time a Java class is loaded. Similarly, the -verbosegc option causes the interpreter to print a message each time a garbage collection is performed. A garbage collection is performed by the runtime system to clean up unneeded objects and to free memory.

    The -verify option causes the interpreter to run the bytecode verifier on all code loaded into the runtime environment. The verifier’s default function is to only verify code loaded into the system using a class loader. This default behavior can also be explicitly specified using the -verifyremote option. The -noverify option turns all code verification off.

    The -D option enables you to redefined property values. PropertyName specifies the name of the property you want to change, and NewValue specifies the new value you want to assign to it.

    The Compiler

    The Java compiler (javac) is used to compile Java source code files into executable Java bytecode classes. In Java, source code files have the extension .java. The Java compiler takes files with this extension and generates executable class files with the .class extension. The compiler creates one class file for each class defined in a source file. This means that many times a single Java source code file will compile into multiple executable class files. When this happens, it means that the source file contains multiple class definitions.

    The Java compiler is a command-line utility that works similarly to the Java runtime interpreter. The syntax for the Java compiler follows:

    javac Options FilenameThe Filename argument specifies the name of the source code file you want to compile. The Options argument specifies options related to how the compiler creates the executable Java classes. Following is a list of the compiler options:

    • -classpath Path
    • -d Dir
    • -g
    • -nowarn
    • -verbose
    • -O
    The -classpath option tells the compiler to override the CLASSPATH environment variable with the path specified by Path. This causes the compiler to look for user-defined classes in the path specified by Path. The -d option determines the root directory where compiled classes are stored. This is important because many times classes are organized in a hierarchical directory structure. With the -d option, the directory structure will be created beneath the directory specified by Dir. An example of using the -d option follows:

    javac -d ..\ FlowerIn this example, the output file Flower.class would be stored in the parent directory of the current directory. If the file Flower.java contained classes that were part of a package hierarchy, the subdirectories and output classes would fan out below the parent directory.

    The -g compiler option causes the compiler to generate debugging tables for the Java classes. Debugging tables are used by the Java debugger, and contain information such as local variables and line numbers. The default action of the compiler is to only generate line numbers.

    The -nowarn option turns off compiler warnings. Warnings are printed to standard output during compilation to inform you of potential problems with the source code. It is sometimes useful to suppress warnings by using the -nowarn option. The -verbose option has somewhat of an opposite effect as -nowarn; it prints out extra information about the compilation process. You can use -verbose to see exactly what source files are being compiled.

    The -O option causes the compiler to optimize the compiled code. In this case, optimization simply means that static, final, and private methods are compiled inline. When a method is compiled inline, it means that the entire body of the method is included in place of each call to the method. This speeds up execution because it eliminates the method call overhead. Optimized classes are usually larger in size, to accommodate the duplicate code. The -O optimization option also suppresses the default creation of line numbers by the compiler.

  13. #28
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    The Applet Viewer

    The applet viewer is a tool that serves as a minimal test bed for final release Java applets. You can use the applet viewer to test your programs instead of having to wait for HotJava to support the final release of Java. Currently, the applet viewer is the most solid application to test final release Java programs, because the HotJava browser still only supports alpha release applets. You invoke the applet viewer from a command line, like this:

    appletviewer Options URLThe URL argument specifies a document URL containing an HTML page with an embedded Java applet. The Options argument specifies how to run the Java applet. There is only one option supported by the applet viewer, -debug. The -debug option starts the applet viewer in the Java debugger, which enables you to debug the applet. To see the applet viewer in action, check out Figure 10.1.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.1.





    The MoleculeViewer applet running in the Java applet viewer. Figure 10.1 shows the MoleculeViewer demo applet that comes with the JDK running in the applet viewer. This program was launched in the applet viewer by changing to the directory containing the MoleculeViewer HTML file and executing the following statement at the command prompt:

    appletviewer example1.htmlexample1.html is the HTML file containing the embedded Java applet. As you can see, there’s nothing complicated about running Java applets using the applet viewer. The applet viewer is a useful tool for testing Java applets in a simple environment.

    The Debugger

    The Java debugger (jdb) is a command-line utility that enables you to debug Java applications. The Java debugger uses the Java Debugger API to provide debugging support within the Java runtime interpreter. The syntax for using the Java debugger follows:

    jdb OptionsThe Options argument is used to specify different settings within a debugging session. Because the Java debugger is covered in detail in Chapter 36, “Java Debugging,” you won’t learn any more details about it in this chapter. If you are just dying to know more about Java debugging, feel free to jump ahead to Chapter 36 and get the whole scoop.

    The Class File Disassembler

    The Java class file disassembler (javap) is used to disassemble a class file. Its default output consists of the public data and methods for a class. The class file disassembler is useful in cases where you don’t have the source code for a class, but you’d like to know a little more about how it is implemented. The syntax for the disassembler follows:

    javap Options ClassNamesThe ClassNames argument specifies the names of one or more classes to be disassembled. The Options argument specifies how the classes are to be disassembled. The disassembler supports the following options:

    • -c
    • -p
    • -h
    • -classpath Path
    • -verify
    • -version
    The -c option tells the disassembler to output the actual bytecodes for each method. The -p option tells the disassembler to also include private variables and methods in its output. Without this option, the disassembler only outputs the public member variables and methods. The -h option specifies that information be created that can be used in C header files. This is useful when you are attempting to interface C code to a Java class that you don’t have the source code for. You’ll learn much more about interfacing Java to C code in Chapter 38, “Native Methods and Libraries.”

    The -classpath option specifies a list of directories to look for imported classes in. The path given by Path overrides the CLASSPATH environment variable. The -verify option tells the disassembler to run the verifier on the class and output debugging information. Finally, the -version option causes the disassembler to print its version number.

    The Header and Stub File Generator

    The Java header and stub file generator (javah) is used to generate C header and source files for implementing Java methods in C. The files generated can be used to access member variables of an object from C code. The header and stub file generator accomplishes this by generating a C structure whose layout matches that of the corresponding Java class. The syntax for using the header and stub file generator follows:

    javah Options ClassNameThe ClassName argument is the name of the class to generate C source files from. The Options argument specifies how the source files are to be generated. You’ll learn how to use the Java header and stub file generator in Chapter 38. For that reason, you won’t get into it in any more detail in this chapter.

    The Documentation Generator

    The Java documentation generator (javadoc) is a useful tool for generating API documentation directly from Java source code. The documentation generator parses through Java source files and generates HTML pages based on the declarations and comments. The syntax for using the documentation generator follows:

    javadoc Options FileNameThe FileName argument specifies either a package or a Java source code file. In the case of a package, the documentation generator will create documentation for all the classes contained in the package. The Options argument enables you to change the default behavior of javadoc.

    Because the Java documentation generator is covered in detail in Chapter 37, “Java Documentation,” you’ll have to settle for this brief introduction for now. Or you could go ahead and jump to Chapter 37 to learn more.

    Applet Demos

    The JDK comes with a variety of interesting Java demo applets, all including complete source code. Following is a list of the demo Java applets that come with the JDK:

    • Animator
    • ArcTest
    • BarChart
    • Blink
    • BouncingHeads
    • CardTest
    • DitherTest
    • DrawTest
    • Fractal
    • GraphicsTest
    • GraphLayout
    • ImageMap
    • ImageTest
    • JumpingBox
    • MoleculeViewer
    • NervousText
    • ScrollingImages
    • SimpleGraph
    • SpreadSheet
    • TicTacToe
    • TumblingDuke
    • UnderConstruction
    • WireFrame
    Rather than go through the tedium of describing each of these applications, I’ll leave most of them for you to explore and try out on your own. However, it’s worth checking out a few of them here and discuss how they might impact the Web.

    The first demo applet is the BarChart applet, which is shown in Figure 10.2.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.2.



    The Barchart Java applet.

    The BarChart applet is a good example of how Java could be used to show statistical information on the Web graphically. The data represented by the bar graph could be linked to a live data source, such as a group of stock quotes. Then you could actually generate a live, to the minute, dynamically changing stock portfolio.

    The GraphicsTest applet is a good example of how to use Java graphics. Java includes an extensive set of graphics features, including primitive shapes and more elaborate drawing routines. Figure 10.3 shows what the GraphicsTest applet looks like.

    Keeping the focus on graphics, the SimpleGraph applet shows how Java can be used to plot a two-dimensional graph. There are plenty of scientific and educational applications for plotting. Using Java, data presented in a Web page could come to life with graphical plots. SimpleGraph is shown in Figure 10.4.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.3.



    The GraphicsTest Java applet.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.4.

    The SimpleGraph Java applet.



    On the business front, there’s nothing like a good spreadsheet. The SpreadSheet Java applet shows how to implement a simple spreadsheet in Java. I don’t think I even need to say how many applications there are for interactive spreadsheets on the Web. Check out the SpreadSheet applet in Figure 10.5.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.5.





    The SpreadSheet Java applet. Once you’ve gotten a headache playing with the SpreadSheet applet, it’s time to blow off a little steam with a game. The TicTacToe applet demonstrates a simple Java version of TicTacToe. This demo opens a new window of opportunity for having fun on the Web. Games will no doubt be an interesting application for Java, so keep your eyes peeled for new and interesting ways to waste time on the Web with Java games. The TicTacToe applet is shown in Figure 10.6.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.6.





    The TicTacToe Java applet. The last applet you’re going to look at is the UnderConstruction applet, which is a neat little applet that can be used to jazz up unfinished Web pages. This applet shows an animation of the Java mascot, Duke, with a jackhammer. It also has sound, so it’s a true multimedia experience! Although this applet is strictly for fun, it nevertheless provides a cool alternative to the usual “under construction” messages that are often used in unfinished web pages. The UnderConstruction applet is shown in Figure 10.7.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 10.7.





    The UnderConstruction Java Applet. Although running these demo applets is neat, the real thing to keep in mind is that they all come with complete source code. This means that you can rip them apart and figure out how they work, and then use similar techniques in your own Java programs. The most powerful way to learn is by example, and the demo applets that come with the JDK are great examples of robust Java applets.

    API Source Code

    The final component of the Java Developer’s Kit is the source code for the Java API. That’s right, the JDK comes with the complete source code for all the classes that make up the Java API. Sun isn’t concerned with keeping the internals of Java top secret. They followed the lead of the UNIX world and decided to make Java as available and readily understood as possible. Besides, the real value of Java is not the specific code that makes it work, it’s the idea behind it.

    The API source code is automatically installed to your hard drive when you decompress the JDK, but it remains in compressed form. The assumption here is that not everyone is concerned about how the internals of Java are implemented, so why waste the space. However, it is sometimes useful to be able to look under the hood and see how something works. And Java is no exception. So, the API source code comes compressed in a file called src.zip, which is located in the java directory that was created on your hard drive during installation of the JDK. All the classes that make up the Java API are included in this file.

    Summary

    The Java Developer’s Kit provides a wealth of information, including the tools essential to Java programming. In this chapter you learned about the different components of the JDK, including tools, applet demos, and the Java API source code. Although you learn more about some of these tools throughout the rest of the book, it’s important to understand what role each tool plays in the development of Java programs. A strong knowledge of the information contained in the Java Developer’s Kit is necessary to become a successful Java developer.

    However, you shouldn’t stop with the Java Developer’s Kit. There are many third-party tools available and in the works that supplement the JDK and enable you to put together a more complete Java programming toolkit. The next chapter highlights these tools and describes how they impact Java development now, and what they may mean for the future.

  14. #29
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Chapter 11

    Other tools and environments

    Although the Java Developer’s Kit provides the essential Java development tools required to program in Java, there are a variety of other tools and development environments that are poised to make Java programming much easier. Languages like C and C++ have a rich field of development environments and add-on libraries. Many of the same companies that created these C and C++ environments and add-ons are busily working on Java versions of their already popular tools. Some of these tools are even available now.

    In addition to the wave of third-party Java development environments, there are also new Java class libraries that promise to add functionality never before seen on the Web. Using these libraries, you will be able to plug Java classes into your own programs and benefit from Java’s code reuse capabilities. Because Java is truly a cross-platform language, these tools promise to bridge many gaps between different operating systems. What all of this means to you is that your trip through the world of Java development promises to be both dynamic and productive, not to mention fun.

    Development Environments

    The development tools provided with the Java Developer’s Kit are all command-line tools, except for the applet viewer. Even though the applet viewer is invoked from a command line, it provides graphical output and is therefore a graphical tool. Most modern development environments include graphical editors, graphical debuggers, and visual class browsers. Java is too modern a language not to have a modern development interface to match, and Java programmers know this. Fortunately, the software tool developers know this, too. Most of the major players in the development tool business have already announced Java environments. A few companies even have tools in beta and ready for testing.

    These third-party development environments span different operating systems and range from C/C++ environment add-ons to entirely new products. The goal here is to let you in on what development environments are out there and how they impact Java programming.

    Symantec Espresso

    Symantec is the first major PC tool developer to have a working Java development environment on the street. Symantec Espresso is a Java development environment in the form of an add-on to Symantec C++ for Windows 95 and Windows NT. Following is a list of the main features supported by Symantec Espresso:

    • Graphical Programming Editor
    • Visual Editors
    • Project Manager
    • Seamless Integration of the JDK Tools
    • Code Generators
    If you own Symantec C++, you can download Espresso for free. To download Espresso or get the latest news about it, check out Symantec’s Java Web site:

    http://www.symantec.com/lit/dev/javaindex.htmlGraphical Programming Editor

    The graphical programming editor in Espresso provides all the features expected in a modern programming editor. It supports full-color syntax and keyword highlighting, along with providing an integrated macro language for extending the editor. The editor also provides navigational features to jump to any Java declaration inside a Java program or the standard Java class libraries.

    Visual Editors

    Espresso includes a couple of visual editors for managing the many classes involved in Java programming. The Espresso Class Editor enables you to quickly create and navigate through your Java code. With the Class Editor, it is no longer necessary to work with individual Java source code files; you can work directly with Java class definitions and members. This class-centric approach frees you from the limitations of thinking of an application in terms of source files.

    The Espresso Class Editor also enables you to quickly browse any part of an application; you simply enter the name of a class or class member, and the Class Editor locates the corresponding source code and loads it into the editor. You can also create and modify new classes from the Class Editor. Figure 11.1 shows what the Espresso Class Editor looks like in action.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.1.





    The Espresso Class Editor. Espresso also includes a Hierarchy Editor for viewing and managing the logical relationships between classes. Figure 11.2 shows what the Hierarchy Editor looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.2.





    The Espresso Hierarchy Editor. Project Manager

    The Project Manager is a powerful component of Espresso that enables you to organize Java projects more effectively. The Project Manager supports projects within projects so you can keep up with nested libraries and project dependencies. Additionally, different project targets and options can be maintained through the Project Manager.

    When you load or create a project in Espresso, the Project Manager launches a background source parser that automatically parses the Java source code and builds a bank of information about the project. This information is in turn used by the Class and Hierarchy Editors to provide browsing and editing support for all the Java classes in the project.

    Seamless Integration of the JDK Tools

    Espresso seamlessly integrates the JDK tools into the development environment with graphical support for the Java interpreter, compiler, and debugger. You can modify the command line arguments to these tools through graphical dialog box interfaces.

    Code Generators

    Espresso provides two code generation tools, which are sometimes referred to as “wizards.” ProjectExpress is a code generation tool that automatically generates Java skeleton applications based on user preferences. ProjectExpress is useful in importing existing Java code into the Espresso environment. Using ProjectExpress, you specify the project type and then add the source files. ProjectExpress then automatically creates the project and loads the classes into Espresso.

    AppExpress is another code generation tool that comes with Espresso. AppExpress provides an easy way to create new Java projects that are fully functional from the get go. AppExpress is especially useful for beginning programmers, who will greatly benefit from not having to provide the core functionality necessary to get a Java program up and running. The Java code created by AppExpress is perfectly suited for modification by the user, providing a time saving jumpstart on the development process.

    Borland Latte

    Borland, one of the largest development tool makers for the PC, has announced its contender in the Java market: Latte. Borland has stated that Latte will be heavily based on the graphical interface made popular in Delphi. Delphi is Borland’s popular object-oriented Pascal development environment. Unlike Espresso, Latte is slated to be a completely new product. Another interesting twist is the fact that Latte is itself being written in Java.

    The downside to Latte is that there are no alpha or beta versions available as of yet. Borland says that it will deliver the Latte technology in several stages, with the first commercial release scheduled sometime during the first half of 1996. Borland also says that the Latte technology will focus on the following areas:

    • Visual Tools
    • Component-Based Architecture
    • High Performance Compilation
    • Scalable, Distributable Database Access
    For more information on Borland Latte, check out their Java Web site:

    http://www.borland.com/Product/java/java.html

  15. #30
    التسجيل
    03-08-2004
    الدولة
    تركيا
    المشاركات
    3,755

    مشاركة: SAMS PUBLISHING " JAVA UNLEASHED " VOL 1

    Microsoft Visual C++

    Microsoft is the only big PC tool developer that has yet to officially announce a Java development environment in the works. Microsoft has agreed to license the Java technology for their Internet Explorer Web browser, so we can only assume that they are also gearing up to provide a development environment. Whether it will come as a twist on the Visual C++ or Visual Basic products, or as an entirely new product, no one knows.

    Until Microsoft decides how they will enter the Java tools market, the most applicable tool they have for Java development is Visual C++ 4.0. Fortunately, Visual C++ 4.0 is extensible enough to enable you to integrate the Java JDK with it a little.

    The first thing you can do to make Visual C++ more Java friendly is enable color syntax highlighting for Java source files. You can do this on a file by file basis by right-clicking on the editor window after you’ve opened the file. Select Properties from the popup menu and then select “C/C++” from the Languages dropdown list. If you want all Java source files to use C++ highlighting, you can add the java file extension to a key in the Windows Registry. To do this, run RegEdit and add java to the list of file extensions specified by the following key:

    HKEY_CURRENT_USER->Software->Microsoft->Developer->Text Editor->Tabs/Language &Acirc;Settings->C/C++Keep in mind that using C++ highlighting with Java source files isn’t perfect. Visual C++ will still only highlight C++ keywords. The main benefit is that comments will be highlighted.

    A more useful modification to Visual C++ is setting it up to use the Java compiler (javac). The first step is to create a simple batch file that will launch the command-line compiler and display a message notifying you of the compile. You can call the file jcc.bat. Following is the source code for jcc.bat, which should be placed in your java\bin directory:

    @echo offecho Compiling %1...\java\bin\javac %1echo Compile complete.The reason for creating a batch file rather than just calling javac directly from Visual C++ is that it enables you to include more information that will be displayed in the Visual C++ Output window.

    To connect the batch file to Visual C++, select Customize from the Tools menu. Then select the Tools tab on the dialog box. You create a Java Compiler tool entry by first clicking the Add button and then filling out the information requested by the dialog box. First, type in the name of the tool, Java Compiler, and click OK. Then specify jcc.bat as the command in the Command edit box. You need to set the arguments to $(FileName)$(FileExt) in the Arguments edit box. Then set the initial directory to $(FileDir) in the Initial directory edit box. Finally, you need to specify that you want to redirect the output to the Output window, so check the appropriate check box. When you’ve done all this, you should see a dialog box similar to the one shown in Figure 11.3.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.3.





    Setting up the Java Compiler tool using the Visual C++ Customize dialog box. You can now use the Java Compiler tool from the Tools menu to compile Java programs within Visual C++. The Java compiler output is even printed in the Output window of Visual C++! I’ll bet you didn’t know Visual C++ could do that.

    In addition, you can also setup Visual C++ to run the Java applet viewer as a tool. Simply add appletviewer.exe as a tool just as you did for the compiler, but specify the HTML file you want to use in the Arguments edit box. In the Java demo applets, this HTML file is usually named example1.html. You can use this name to make things easier. The correct settings for the Applet Viewer Visual C++ tool are shown in Figure 11.4.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.4.



    Setting up the Java Applet Viewer using the Visual C++ Customize dialog box.

    JavaMaker

    The JavaMaker development environment for Windows 95 and Windows NT is a simple, yet useful programming environment for Java. It is the product of an individual effort by Heechang Choi, and basically serves as a front end for the Java compiler and applet viewer tools. Figure 11.5 shows what JavaMaker looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.5.





    The JavaMaker development environment. For more information on JavaMaker, or to download the latest version, check out the JavaMaker Web site:

    http://net.info.samsung.co.kr/~hcchoi/javamaker.htmlNatural Intelligence’s Roaster

    Natural Intelligence has announced that they have been working on a Macintosh Java development environment based on their popular Quick Code Pro script editor. The Applet Development Kit, also known as Roaster, should be entering a beta release stage at any time. Roaster is touted as having the following features:

    • A complete integrated development environment
    • A powerful programming editor
    • A high-performance compiler
    • A debugger
    • A class disassembler
    • A project manager
    • Power Macintosh support
    The Roaster development environment promises to include multiple clipboards for better organization of code snippets, as well as powerful macro capabilities. The Roaster programming editor will feature context-sensitive font and color highlighting, as well as bookmarks for keeping track of Java code. It will also feature powerful search and replace features, including regular expression matching and batch search capabilities. For more information about Roaster, check out Natural Intelligence’s Roaster Web site:

    http://www.natural.com/pages/products/roaster/Metrowerks CodeWarrior

    Metrowerks, the creators of the popular CodeWarrior C++ development environment for Macintosh, has also announced a Macintosh Java development environment. This new environment, codenamed Wired, is expected to be released as a suite of add-ons for a future release of CodeWarrior. Metrowerks has announced that Wired should be ready for release with CodeWarrior 9, which is scheduled to ship during the summer of 1996. For more information on Wired, take a look at the Metrowerks Web site:

    http://www.metrowerks.com/Silicon Graphics Cosmo

    One of the most interesting Java development environments in the works is Cosmo Code by Silicon Graphics, which is a component of the larger Cosmo Web development system. Cosmo itself is aimed at providing more extensive multimedia and 3D graphics support for the Web. It is the primary development component of Cosmo, and is actually a Java development environment with a lot of promise. Cosmo Code is currently available for Irix systems, and contains the following core components:

    • Visual Builder
    • Graphical Source Debugger
    • Visual Source Browser
    To find out the latest information about Cosmo Code, or to download a copy to try out, refer to the Cosmo Web site:

    http://www.sgi.com/Products/cosmo/Visual Builder

    The Cosmo Visual Builder is an extensible, interactive software development tool that enables you to create Java applets using drag-and-drop. Similar to Silicon Graphics RapidApp product for C++, the Visual Builder enables developers to quickly construct Java programs that use both the Cosmo and Java libraries. The extensibility of the Visual Builder provides a clear path to using new Java components as they become available.

    Graphical Source Debugger

    Cosmo Code includes its own graphical Java source debugger, which supports the following features:

    • Graphical display of Java source while debugging
    • Source-level traps
    • Call stack display
    • Data inspection and expression evaluation
    • Memory functions and explicit garbage collection
    • Thread controls
    • Exception handling support
    Figure 11.6 shows what the Cosmo Code graphical source debugger looks like.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.6.





    The Cosmo Code graphical source debugger. Visual Source Browser

    The Cosmo Code visual source browser is a tool that provides the user with a visual perspective on their Java classes, including graphical class hierarchies. Figure 11.7 shows the Cosmo Code visual source browser in action.

    [img]file:///G:/Java%20Unleashed/figicon.gif[/img]FIGURE 11.7.





    The Cosmo Code visual source browser. Programming Libraries

    Beyond the Java development environments, third-party class libraries make up the other major market for Java tool vendors. Java provides a level of code compatibility and reuse previously unseen in the software world. A tool vendor is capable of creating a single class library in Java that spans all platforms. This opportunity has enormous appeal to tool developers, so expect to see an influx of Java class libraries in the very near future.

    In the present, there are a decent amount of freeware type classes to pick and choose from, along with a few commercial class libraries that will be available any day. As far as getting the freely distributed, or noncommercial classes, check out the Gamelan Web site:

    http://www.gamelan.com/Gamelan provides a staggering array of Java classes, written primarily by individuals, that span many areas of Java programming. The majority of these classes come with complete source code, so they are useful both as tools and as educational resources.

    As far as commercial class libraries go, there aren’t too many options at the moment. One company that appears to be ahead of the pack is Dimension X, who has a couple of Java class libraries nearing completion: Ice and Liquid Reality. You can get the latest information on these libraries from Dimension X’s Java Web site:

    http://www.dnx.com/dnx/java.htmlIce

    Dimension X’s Ice class library is a high-performance 3D rendering package for Java. Ice is composed of two parts: a C library that implements low-level graphics primitives, and a set of Java classes that provide wrappers around the C library. Ice is designed with speed as a primary goal, along with the support of special-purpose 3D graphics hardware. With this in mind, the aim is for Ice to be used to generate interactive 3D graphics on the fly. Ice implements the following features:

    • Z-buffered polygons, lines, and points
    • Gouraud shading
    • Texture mapping
    • Support for up to eight light sources
    • Rich set of light and material properties
    • Fog and depth cueing
    • Support for 8-, 16-, 24-, and 32-bit frame buffers
    • 8-bit dithering
    • Alpha blending
    • Motion-blur and anti-aliasing
    Liquid Reality

    Liquid Reality is the first set of classes to be built on top of the Ice class library. It is composed of a set of Java classes for building dynamic VRML worlds, and uses Ice to handle rendering the worlds. Liquid Reality really just provides one extension to VRML: when the VRML parser encounters a node type that it doesn’t understand, it queries the HTTP server that served the VRML file and requests a Java class describing the unknown node. Liquid Reality effectively provides VRML with the same kind of extensibility that HotJava provides to HTML documents.

    Summary

    As you’ve learned in this chapter, the Java development scene is in a state of rapid growth. The wide variety of third-party tools available now and on the horizon will certainly change the face of Java programming. Armed with the knowledge of what tools are available and what they can do, you should now have more insight into planning your own Java development.

    Additionally, you should realize that the tools mentioned in this chapter are really only the first wave of third-party Java development products. As Java becomes more established, more tool vendors will see the light and take the steps necessary to enter the Java tools marketplace. This is good news for Java users and developers, as competition among tool vendors will result in better development tools and more affordable prices. Just in case it hasn’t occurred to you yet, this is only the beginning!

    Now that you know the whole scoop surrounding the different Java development tools, you’re probably ready to learn about the Java language itself. I mean, it’s fun to talk about the technology, but ultimately the Java language is the nuts and bolts that drive everything. The next part of the book, “The Java Language,” covers all the juicy details of the Java language.

صفحة 2 من 3 الأولىالأولى 123 الأخيرةالأخيرة

ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •