|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
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 routineprintf(). 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 computerat least, in a computer with a single processoronly 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 dont 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, youll 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. Suns 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 Javas 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.
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, its 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 errorsin just 22 lines of code. Java Has a Strong Security ModelJavas 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 Javas security model. See Chapter 41, Security, to learn how Java provides securityparticularly for network applications. See the next section, Whats New in Java, to learn more about those security enhancements. Whats 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 Suns Java Development Kit (JDK). The JDK also includes a variety of toolsits a must-have item for any Java developer. (Youll have to supply your own text editor.)
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 EnhancementsRecall from earlier in this chapter, in the section entitled Java Has a Strong Security Model, that tight security is one of Javas distinctives. Its not surprising that JDK 1.2 includes some major improvements in security. These changes include
Policy-Based Access Control If youve used the UNIX operating system, youre 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 themalthough 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 appletsalthough 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.
|
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. |