What Is Java?


Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Chapter 1.  Introduction to Java

Java is a high-level programming language that has many functions. It is used to develop applets that reside on Web pages, applications that run on your desktop, server-side middleware that are used to communicate between clients and server resources. Java is also used on Web servers and in embedded systems and smart devices, just to name a few of its many functions. The practical applications of Java can be found in Web browser applets and in server-side applications (Web and enterprise-wide).


The following is a short history of the Java programming language and the reasons for its inception. In 1991, a research group working as part of Sun Microsystems's "Green" project, was developing software to control consumer electronic devices. The goal was to develop a programming language that could be used to control and network "smart" devices, such as televisions, toasters, and even buildings. These devices would all coexist and communicate with one another.

The first prototype that Sun came out with was a device called the Star7 a device, similar to a remote control, that could communicate with other Star7 devices. The initial intent was to use C++ to control the Star7, but as a result of frustration with that language, Green project member James Gosling developed a new language called Oak to control the Star7. The title Oak came from a tree that Gosling could see from his office window while developing the language. Sun later replaced the name with Java because Oak was already being used.

As a result of Oak, or Java, being designed to run on small appliances, the language had the following inherent benefits:

  • It was small, so it could run on the limited memory of small appliances.

  • It was efficient and reliable, so it could function as a small appliance we are all used to computer crashes, but a microwave oven crash is not acceptable.

  • It was portable, so it could run on different pieces of hardware.

In 1994, the members of the Green project developed a World Wide Web (WWW) browser completely in Java that could run Java applets to demonstrate the power of the language. The browser was originally called WebRunner, but is now known as HotJava. Java came alive in 1995, however, when Netscape licensed the Java programming language and included support for it in its Navigator product.

In 1997, Sun released the Servlet API, which revolutionized server-side Web development and moved it away from monolithic CGI scripts or proprietary solutions. In 1999, Sun released the first version of the Java 2, Enterprise Edition (J2EE) specification that included JavaServer Pages (JSP) and Enterprise JavaBeans (EJB) in a highly distributed enterprise middleware. Since then the J2EE specification, along with the JSP, Servlet, and EJB specifications, have evolved into a very powerful programming paradigm.

Why Use Java?

You might have heard some of the geeks in your office talking about Java, or maybe you are taking a Java class in school, or perhaps you already know what Java is, but aren't too sure why you would want to use it. Here are some reasons to learn Java, regardless of which category you fall under.

  • Java is a truly object-oriented programming language, perfect for modeling the real world and solving real-world problems. It will adapt to the latest design methodologies, and it provides extensibility so that your large project will be manageable.

  • Java is platform independent, so the same semicompiled byte code will work on Microsoft Windows, Unix, Apple Macintosh, Linux, and any future Wiz-bang operating system that implements a Java virtual machine.

  • Java can add interactivity to your Web pages. Java applets provide much of the functionality you are probably already familiar with, such as menus, data entry forms, and other user interface components as well as some of the neat drawings and animated graphics that are found on most Web pages.

  • With increasing CPU speeds, Java is becoming more feasible for building usable applications.

  • Java's new SWING libraries rival components you see in the Microsoft Windows operating systems: tree controls, tab controls, list controls, tables, and so on.

  • Java has an incredible future in the upcoming decade! There is more and more talk about "intelligent devices" hosting a Java virtual machine that can run Java programs. These devices, such as smart toasters, smart televisions, and smart houses, will be networked together so that your television can tell your VCR to tell your toaster to start toasting! Java is the forefront technology of this exciting, evolving field.

Java has existed in its infancy for the past couple years, demonstrating conceptual leaps and bounds and accomplishing the unthinkable. As it evolves and matures, it is more and more apparent that Java will become the prevalent development language of the future. Learning Java will not only help you develop incredible applets and applications now, it will also prepare you for the future of computer and device programming!

Java Buzzwords

The following buzzwords are associated with Java; this section defines those buzzwords and explains how they are applicable to Java:

  • Simple

  • Object oriented

  • Distributed

  • Robust

  • Secure

  • Architecture neutral

  • Portable

  • Interpreted

  • Multithreaded


Java is simple to learn and simple to implement. Its syntax is very similar to C++ and C#, and it touts all the standard programming paradigms in an easy-to-use fashion. In fact, one of Java's goals is to enable its developers to be up-and-running fast. Furthermore, it is consistent; when you learn how something works, you can rest assured that it will not change on you as you encounter a similar topic.

Object Oriented

Java is a truly object-oriented programming language that supports objects, inheritance, and polymorphism; this makes it ideal for establishing a good foundation in computer programming. We will discuss objects and object-oriented programming starting in Chapter 6, "Classes," but the main benefit of it is that you can model your Java programs after real-life objects, such as an apple, a car, or a person. This programming paradigm helps bridge the gap between the way a machine thinks and the way you do.


Connectivity between components has been a basic tenet of the Java programming language since its inception. Java's developers have remained true to this belief as the technology has evolved. Hence, developing applications that run on multiple machines concurrently and communicate with one another is far easier and efficient using Java than with many other programming languages.


Java's modest beginnings as a simple mechanism to add interactivity to Web pages and develop simple communication schemes are a distant memory. Today Java boasts a graphical user interface (GUI) library that rivals features of the best operating systems; a Web development solution that surpasses any other offering; a distributed enterprise platform that leads the market; and a rich set of libraries for data input and output, multithreading, advanced imaging, XML document manipulation, and more. Almost any feature you could be searching for in a programming language you will find in Java.


Remember that Java's inception was designed around the communication between smart devices. This legacy added a set of very strict rules governing what it can and cannot do. Various components of the Java programming language operate in different secure environments. For example, applets running in a Web browser cannot access a Web client's underlying file system or any other Web site other than that from which it originated; a distributed component must be granted access to communicate with other hosts; and all Java programs run in a virtual machine that protects the underlying operating system from harm.

Architecture Neutral

Because Java runs inside of a Virtual Machine (a program written in operative system specific code that provides a common front-end to all operating systems) it in no way depends on the underlying operating system or hardware. Again this was another of the basic tenets of Java's existence: to be able to run on any device.


Applications developed in Java are compiled into byte-code, which consists of instructions that a Virtual Machine will translate to operating system specific instructions. Because of this, any Java code that you write and compile into byte-code will run on any operating system for which there exists a compatible Virtual Machine. Hence, the phrase: write once, run anywhere. The joke in the industry used to be write once, debug everywhere, but that is becoming less of a concern, especially in the server-side arenas.


Java is interpreted, which means that it is not compiled into machine-specific code until it is executed. Interpreted code tends to run much slower than fully compiled code, but Java gains some performance because it is partially compiled into byte-code. The partial compilation further benefits Java in that Java applications shipped to customers are not shipped as pure source code that can be easily read, but in a binary form.


Multithreaded applications have the capability to run multiple things at the same time, for example a multithreaded application can display a graphical user interface to a user while downloading stock quotes from the Internet and computing historical averages. Java's threading model was designed into the language from the beginning and is eloquently implemented, as you will learn later in the book.


    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net