Sams Teach Yourself Java 2 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- About the Technical Editor
- Acknowledgments
- We Want to Hear from You!
- Reader Services
- Introduction
- Hour 1. Becoming a Programmer
- Hour 2. Writing Your First Program
- Hour 3. Vacationing in Java
- Hour 4. Understanding How Java Programs Work
- Part II: Learning the Basics of Programming
- Hour 5. Storing and Changing Information in a Program
- Hour 6. Using Strings to Communicate
- Hour 7. Using Conditional Tests to Make Decisions
- Hour 8. Repeating an Action with Loops
- Part III: Working with Information in New Ways
- Hour 9. Storing Information with Arrays
- Hour 10. Creating Your First Object
- Hour 11. Describing What Your Object Is Like
- Hour 12. Making the Most of Existing Objects
- Part IV: Programming a Graphical User Interface
- Hour 13. Building a Simple User Interface
- Hour 14. Laying Out a User Interface
- Hour 15. Responding to User Input
- Hour 16. Building a Complex User Interface
- Part V: Creating Multimedia Programs
- Hour 17. Creating Interactive Web Programs
- Hour 18. Handling Errors in a Program
- Hour 19. Creating a Threaded Program
- Hour 20. Reading and Writing Files
- Part VI: Creating Multimedia Programs
- Hour 21. Using Fonts and Color
- Hour 22. Playing Sound Files
- Hour 23. Working with Graphics
- Hour 24. Creating Animation
- Part VII: Appendixes
- Appendix A. Tackling New Features of Java 2 Version 1.4
- Appendix B. Using the Java 2 Software Development Kit
- Appendix C. Programming with the Java 2 Software Development Kit
- Appendix D. Using Sun ONE Studio
- Appendix E. Where to Go from Here: Java Resources
- Appendix F. This Book's Web Site
Going to School with Java
As a medium that offers a potential audience of millions, the World Wide Web includes numerous resources for educators and schoolchildren. Because Java programs can offer a more interactive experience than standard Web pages, some programmers have used the language to write learning programs for the Internet.
For one of the strongest examples of this use of Java, visit http://www.npac.syr.edu/projects/vishuman/VisibleHuman.html.
This Web site uses data from the National Library of Medicine's Visible Human Project. The project is a database of thousands of cross-sectional images of human anatomy. A Java program is being used to enable users to search the collection and view images. Instead of making requests by text commands, users make the requests to see different parts of the body by using the mouse, and the results are shown immediately in graphic detail. The Java program is shown in Figure 3.2.
Figure 3.2 Images from the National Library of Medicine's Visible Human Project can be viewed interactively on the Web using a Java program.
Numerous educational programs are available for many different computer systems, but what makes this program remarkable is its versatility. The Visible Human Project tool is similar in function and performance to CD-ROM software that users might run on their computer systems. However, it is run directly from a Web page. No special installation is needed, and unlike most CD-ROM software, it isn't limited to PC-compatible and Macintosh systems. Just like Web pages, Java programs can be run on any computer system that can handle them.
To be able to handle Java programs, a Web browser must have a Java interpreter. The interpreter included with a browser serves a similar function as the interpreter you used to run the Saluton program during Hour 2, "Writing Your First Program." The difference is that a browser's interpreter can only run Java programs that are set up to run on Web pages and cannot handle programs set up to run from the command line. Currently, Java-enabled browsers are available for most systems, including PCs running a version of Microsoft Windows, Apple Macintosh systems, SPARC workstations, and computers running the Linux operating system.
The primary Java-capable browsers in use today are Microsoft Internet Explorer, Netscape Navigator, Mozilla, and Opera. Although versions of these browsers support Java, none of them offer built-in support for Java 2. Browser developers have not been able to keep up with new versions of the language as quickly as Sun produces them, and at this time, it appears that all of the companies have given up trying to support anything beyond Java 1.1.
To make it possible for Java programmers to rely on Java 2 support in browsers, Sun has developed the Java Plug-in, a Java interpreter that works as a browser enhancement. By specifying in the coding of Web pages that this interpreter should be used instead of the one built into the browser, Java programmers can take advantage of all features of the language in their Web-based programs.
A Java program such as the Visible Human Project database does not have to be written for a specific computer system. This advantage is called platform independence. Java was created to work on multiple systems. Originally, Java's developers believed it needed to be multiplatform because it would be used on a variety of appliances and other electronic devices.
The programs you write with Java can be run on a variety of computer systems without requiring any extra work from you. This advantage is one of the primary reasons so many people are learning to write Java programs and are using them on software projects. Many professional software companies are using Java for the same reason. Under the right circumstances, Java can remove the need to create specific versions of a program for different computer systems. The potential audience for software grows with a multiplatform solution such as Java.
Lunch in JavaWorld | Next Section

Account Sign In
View your cart