The Java language was designed at Sun Microsystems over a 5 year period, culminating in its first release in January, 1996. The developers, led by James Gosling, originally had in mind building a language for controlling simple home devices with embedding microcomputers. Thus, they started with the object oriented concepts of C++, they simplified it and removed some of the features such as pointers that lead to serious programming errors.
While the team may originally have had in mind compiling this language for a specific microprocessor, they developed both the Java language and a hypothetical processor called the Java Virtual Machine or JVM. The Java compilers they developed produced binary code designed to execute on this JVM rather than on a PC or Sun workstation.
They relate that their working name for this evolving language was "Oak," but as it neared completion they found that this trademark was already registered. So, the story goes, they came up with the name "Java" while taking a break at a coffee shop.
Then, to actually execute Java programs, they developed Java interpreters that ran on various machines and under various operating systems. Thus, Java became a language that would execute on a number of systems and now has implementations for virtually all common computers and operating systems.
Sometime during development, it suddenly became obvious that Java would be an ideal language for use in the rapidly exploding Internet. They added a window manager to allow easy development of user interfaces and added network communication methods such as web page URLs and sockets.
Since Java could now run on nearly any kind of workstation, it became an ideal vehicle for adding powerful computational capabilities to web pages. You could browse these pages from any platform and see the same behavior in the embedded Java program.
A Java applet is a program designed to be embedded in a web page. Applets can be quite complex: they are not limited to simple animations or single windows and may access remote databases or other sources of information, and may load and operate on complex information on your computer system.
Java applets are designed to be quite secure, however, so that they can be safely downloaded over a network without your being concerned that they might be able to do damage or mischief to your computer.
They cannot write any information onto your hard disk unless you specifically declare a directory which applets have access to. They cannot access any other resources on your network or any other hardware or peripherals on your computer.
The Netscape version 2.x and 3.x browsers impose additional protection: they do not allow applets to write any files to your disk even if you define a directory which you allow applets to write to.
Java applets are also restricted from writing into memory outside the Java address space. This is accomplished mainly through the fact that Java has no memory pointer type and thus cannot have this pointer pointing to memory a malicious programmer might want to attack. Java applets are also scrutinized class by class as they are loaded by the run time environment in your browser, and checks are made to assure that the binary code has not been modified such that it might interact with or change any part of the memory of your system.
Further, applets cannot access resources on any other computer on your network or elsewhere on the Internet with one exception: they can open TCP/IP connections back to the machine running the web server they were downloaded from.
To add even more protection and prevent programmers from spoofing users into giving them confidential information, all windows which you pop up from an applet have a banner along the bottom reading "Untrusted Java Applet." This is to prevent hackers from designing an exact copy of a familiar screen and luring users to type confidential information into it.
By contrast, Java applications are full-featured programs which run on your computer and have full access to its resources. They can read, write, create and delete files, and access any other computer on the network.
You will quickly appreciate that it is possible to develop full-fledged applications in Java: database viewers, word processors, spreadsheets, math packages, file and network manipulation programs. In fact, one of the great strengths of Java is that it makes accessing other computers on your network extremely easy.
Now you can write quite sophisticated programs in
Visual Basic as well, so you might ask whether Java is really
"ready" for all this attention. Can you write real,
significant programs in Java? Figure 1-1 shows a simple data entry
program for a search tool, allowing you to enter terms as well
as Boolean conditions from drop-down list boxes. Figure 1-2 shows
the exact same program created in Java.
Figure 1-1: A simple search query entry form, written
in Visual Basic.
Figure 1-2: The same simple search query entry form
written in Java.
Both of these are complete, working programs and their sources and binaries are included on the example disk, under \chapter1, If you want to see how they work.
But what about Java? How does it really stack up? Is it real or is it a toy? Let's take a moment and look at some of the advantages of each language.
With all of these pluses, the only possible drawback is that you'll have to learn a new language. This is, of course, what this book is about and we'll see some very significant advantages to Java as we begin to explore it.
So far, we've looked at the reason Java was designed
and compared it briefly to Visual Basic. Next we'll look at
how to install Java and compile Java programs.
Then, to become fluent in Java, you'll need to learn two things: Java's syntax, and the
rationale behind object oriented programming. We'll take these
up in the following chapters, and soon you, too, will be a Java
expert.
Java and
all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and other countries.