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


Java Supports the Client/Server Model One of the design goals of C (and later, C++) was to keep platform-specific capabilities out of the core language. Thus, in C and C++ nothing exists in the language itself that enables you to output any information. Instead, you call a library routine—printf().

Java has adopted this aspect of C++’s design and has extended the standard libraries to include network communications. In Java, for example, you can open a connection to a Web page or other Internet application and read or write data, in much the same way as a C or C++ programmer reads or writes to the local terminal. This design decision makes it easy to write Internet-aware applications in Java. In fact, HotJava, the Java-aware Web browser written by Sun, is written entirely in Java.

Java Supports Concurrency In the real world, different objects do their work simultaneously. In a computer—at least, in a computer with a single processor—only one set of instructions can be executing at a time. To help programmers build applications that more accurately reflect the way the real world works, operating system developers introduced multitasking. In a multitasking operating system, two or more applications can share a single processor, with each having the illusion that it has the processor to itself.

Each such application (often called a process) has its own protected part of memory where it stores its data. In most operating systems, one process cannot accidentally interfere with another process. In fact, these operating systems include special function calls (called Inter-Process Communication or IPC) that enable one process to send or receive data from another.

At the operating-system level, a significant amount of work is required to start a process or to switch from one process to another. Programmers asked for, and got, a “lightweight process” called a thread. In general, threads don’t offer the bulletproof protection of processes, but they can be started and used more quickly.

The biggest problem with processes and threads is that these facilities are offered by the operating system. If you write a program to run in a Windows NT environment, you’ll have to modify the parts that start and control processes and threads if you port the code to, say, UNIX. In some operating systems, such as older versions of Microsoft Windows, no facilities at all may exist for multitasking.

Sun’s solution was to make threads a part of the language itself. Thus, if you write a multithreaded Java application, that application will run on any supported platform, including Windows, UNIX, and Mac OS. Further, because Java’s object-oriented model restricts the way one application can communicate with another, Java threads have some of the same safeguards as processes, with little of the overhead.

  To learn more about Java threads, see “Adding Animation” on p. 1104.

Suppose, for example, you wanted to explore what happens in a particular Web application when many users access the same page at the same time. In a multitasking operating system such as UNIX, you might write an application that makes several copies of itself. (In UNIX, such a process is called forking. In Windows NT, it’s called spawning.) In older operating systems, such as Windows 3.1, you might decide to enlist the help of several friends and have everybody press the Enter key at once. In Java, you can write an application that reads the number of simultaneous connections from the command line, opens the specified number of threads, reads the same Web page in each thread, and reports out any errors—in just 22 lines of code.

Java Has a Strong Security Model

Java’s designers have always been able to boast that their language was among the most secure. The latest release, in JDK 1.2, has several enhancements to Java’s security model. See Chapter 41, “Security,” to learn how Java provides security—particularly for network applications. See the next section, “What’s New in Java,” to learn more about those security enhancements.

What’s New in Java?

To write Java you need an editor, a Java compiler, and a Java Runtime Environment. The easiest way to get a Java compiler and runtime environment is to download Sun’s Java Development Kit (JDK). The JDK also includes a variety of tools—it’s a “must-have” item for any Java developer. (You’ll have to supply your own text editor.)


After you’ve learned Java, you may want to look at some of the Integrated Development Environments (IDEs) being offered by Microsoft, Symantec, and others. These environments typically enable you to write Java faster, although not all of them give you access to the latest Java features.

Sun continues to improve Java and periodically issues a new version of the JDK. The latest version, JDK 1.2, was released to the general public late in 1998. JDK 1.2 introduces a few changes to the language itself, adds a large number of new APIs, and includes some new tools. This section reviews of the new features in JDK 1.2.

Security Enhancements

Recall from earlier in this chapter, in the section entitled “Java Has a Strong Security Model,” that tight security is one of Java’s distinctives. It’s not surprising that JDK 1.2 includes some major improvements in security. These changes include

  Policy-based access control—The capability to grant rights to software based on an external configuration file.
  Support for X.509v3 certificates—You can use the latest industry-standard encryption technology to sign the Java Archives in which you distribute your classes.
  New security tools—Including tools to manage certificates and write your security policy file.

Policy-Based Access Control If you’ve used the UNIX operating system, you’re familiar with the concept of permissions. The owner of a file can grant other users (or programs) the right to read, write, or execute a file. Processes take on the rights of the person who started them—although some users will choose to restrict the rights of programs they launch. (For example, Web servers are often started by someone with root authority, but run as the non-privileged user nobody.)

Beginning in version 1.2, Java developers have similar choices with their applications and applets—although the level of control is finer grained than that offered by many UNIX implementations.

Computer resources include files, directories, hosts, and ports. The person responsible for a computer that will be running Java can set up a security policy that specifies who is allowed to access each resource. Access includes read and write permission (for files and directories) and connect permission (for hosts and ports). The security policy is specified in an external security configuration file.


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.