home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Table 37.3 Basic Language Constructs (Control Flow)

Construct Example

if...then...else if (i >= theSalesGoal) { ... }
for for (i=0; i < MAXITEMS; i++) {...}
while while (i < theSalesGoal) { ... }
do...while do { ... } while (i < theSalesGoal);
switch (...) case switch (i) { case FIRST: ... break; ...}
break while (i < theSalesGoal) { if (i==10) break;...}
continue while (i < theSalesGoal) { if (i==10) continue; ... }
labeled break while (i < theSalesGoal) { if (i==10) break my_label;...}

Table 37.4 Basic Language Constructs (Java Comments)

Comment style Format Notes

C comments /* ... */ can span multiple lines
C++ comments // ... comment stops at the end of the line: less prone to error
javadoc comments /** ... */ appropriate for header comments: automatically generates program documentation

ON THE WEB
http://java.sun.com/docs/index.html This site contains Sun’s official Java documentation, including reference manuals and language tutorials.

Leveraging Java Classes and Packages

Although operators and data types are obviously very important in Java, classes are where the real action is.

A class is a group of objects with similar properties (attributes), common behavior (operations), common relationships to other objects, and common semantics. An object, on the other hand, is an instance of a class, dynamically created by the program during runtime. In other words, classes define objects; objects, on the other hand, are specific, concrete instances of a class.


NOTE:  In most languages, you can place related routines or classes into a library. Java is no exception—here libraries are called packages. We’ll talk more about packages when we build our first applet later in this chapter.

This discussion is continued later in this chapter. For now, however, it is time to get on with the fun stuff: coding and running your very first Java applet!

Installing the JDK

Many excellent, graphical tools for developing Java applets are on the market. These tools are called Integrated Development Environments, or IDEs. For professional development, you’ll probably want one of these tools. Regardless of which IDE you—or your company—choose, you should still be familiar with Sun’s command-line JDK. Several reasons for this are

  Periodically uploading and installing Sun’s current JDK is the best way to “keep up to speed” with all the latest Java APIs.
  The JDK is an excellent “reference platform” to make sure your code is portable to as wide an audience as possible.
  The JDK is easy to install; it doesn’t take an excessive amount of disk space; it contains some excellent tools; and it is absolutely free.
ON THE WEB
http://www.javasoft.com/ You can download a free copy of the latest Java JDK at this URL.

Minimum Requirements

Sun has targeted Java to run on any machine. It has focused its JDK development efforts on a smaller group. This section describes the minimum hardware and operating system requirements needed for the JDK.

Your Computer Although Java runs on nearly every computer, the JDK itself runs on fewer machines. The following is the list of hardware and operating system combinations supported by Sun:

  Microsoft Windows 95
  Microsoft Windows NT 4.0
  Sun Solaris 2.4, 2.5, 2.5.1, and 2.6 on SPARC
  Sun Solaris 2.5, 2.5.1, and 2.6 on x86

If you need to run the JDK but don’t have Windows or Solaris, don’t despair. Many hardware vendors have ported the entire JDK to their machines. See the comments on “Other JDKs,” later in this section.

Disk Space A typical copy of the JDK installer requires about 10MB. The installer will expand into a set of files about twice its size. Thus, you should budget around 30MB to get started. (You can delete the installer itself after you’re done if you need to free up the space.)

You’ll also want to allow another 30MB for the documentation. If you’re tight on space, you can use the online version, but it’s slower than a local copy.


NOTE:  Windows users need to be running Windows 95, Windows NT, or higher to develop Java applets because Java requires a 32-bit operating system and long, case-sensitive filenames.

Other JDKs

If you’re not using a common operating system such as Sun’s Solaris or Microsoft’s Windows NT, don’t worry. Even though a Sun JDK may not be available for your computer, you may still be able to develop Java programs. Check with your computer vendor to see if it has ported the JDK to your operating system.

IBM, for example, has released versions of the JDK for AIX (IBM’s version of UNIX), OS/400 (which runs on the popular AS/400), and OS/390 (a mainframe operating system).

ON THE WEB
http://java.sun.com/cgi-bin/java-ports.cgi Find out which operating systems support Java by running the Sun Web application at this address. Note that not all operating systems that support Java support a JDK.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.