Java Overview


Mike Yawn
Hewlett-Packard
Commercial Systems Division
19447 Pruneridge Avenue
Mailstop 47UA
Cupertino, CA 95014
myawn@cup.hp.com

CONTENTS

  • I. Theoretical Stuff
    A. The Java Language
    B. The Java Virtual Machine
    C. The Java Platform
    D. How does Java measure up?
  • II. Practical Stuff
    A. Obtaining Java
    B. Installing Java
    C. Java Directory Structure
    D. Java Components
    E. Using Java
    F. Where to go for more info
  • III. Java and Databases
  • IV. The Java Native Interface
  • i. theoretical stuff

    In this paper, we'll be looking at Java from a number of perspectives. Because this is a tutorial, I want to cover some of the nuts-and-bolts stuff like how to download and install Java, and then how to write, compile, and execute a simple Java program. However, with Java being a relatively new technology, I also want to take some time to explain Java - what it is, what it can do, and why it has received so much attention in the press. We'll also examine how well it works for doing typical MPE types of things like accessing databases, as opposed to typical web-oriented tasks such as animating an HTML page. We'll cover the theoretical areas first, and save the practical information for the end.

    i-a. the java language

    Every industry publication today is filled with discussion of "Java". If you've read the various claims for and against Java, you may have become thoroughly confused by the often conflicting information: is Java secure? is it portable? is it appropriate for "mission critical" use?

    Part of the confusion stems from the fact that the term "Java" is used to refer to several distinct parts of a computing platform. In order to make sense of the claims, you need to understand the various pieces and how they relate. We'll look in detail at three key components: The Java programming language, the Java Virtual Machine, and the Java Platform, or Java APIs. Javascript, which you may have heard of or seen also, has absolutely nothing whatsoever to do with any component of Java, and is merely Netscape's attempt to associate their HTML scripting language with Java.

    Sun Microsystems, where Java was developed, used the following bit of marketing-speak very early on in Java's life to describe the product's benefits:

    Java: A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic language.

    There is nothing radically new here; each of these attributes can be applied to one or more languages that were already in existence. But as computing has evolved, the relative importance of these traits has changed: mainframe programmers were much more willing to sacrifice simplicity and portability for performance. Early UNIX implementations demonstrated the willingness to sacrifice virtually everything for the sake of an illusion of portability. The emergence of the World Wide Web, pervasive graphical clients, and advances in software engineering such as object-oriented programming all set the stage for Java, which strikes a balance between all these attributes which meets the requirements of today's distributed computing environments better than any language up to this point.

    If you examine the most popular languages in computing history, you'll find that each one had some unique niche where it originally flourished. Languages that never find such a niche are doomed to perish, or become a curiosity. For those that do find a niche, they either grow beyond it and become more widely adopted, or they remain tied to it and fade away when the next wave of computing arrives. Both COBOL are RPG had origins closely tied to Unit Record equipment. COBOL grew beyond its roots, and became the most widely used language for business data processing. RPG code still exists, but its heyday faded with the passing of the keypunch machine. C gained prominence because of its close ties to the UNIX operating system; but the extensive use of UNIX in universities virtually assured the language of a wider use as it became the most widely known language for new entrants into the IT labor pool. Java first gained widespread notoriety because of its inclusion of basic internet functionality - such as URL handling, MIME data types, and Sockets connections - as part of its original basic API set. Java now appears well poised to break away from this niche and become the next widely-adopted language for general purpose computing. The reasons for this leap will be covered in upcoming sections.

    We won't cover each of the claims made for Java above, but a few are worth a little more attention:

    Java is a truly object-oriented language. For those of you who aren't already believers in the benefits of object-oriented programming styles, object-oriented code is more maintainable, more reusable, and more modular than code written in non-object-oriented fashion. C++ is a hybrid, adding many object-oriented features to C, but not addressing some of that language's heinous shortcomings.

    Java is a simple language to use. Automatic garbage collection means that users can have the benefits of dynamically created objects, but without the need to manage memory and worry about proper deallocation. Java provides references to objects, but does not allow these references to be used as pointers in numeric expressions or cast to incorrect types. Java provides numerous sanity-checking features, such as array bounds checking, to help ensure the correctness of programs.

    Java provides an inherent portability missing in other languages, by leaving virtually nothing as an implementation-defined detail. Word size and byte order are defined by the language; there are no #pragma or #ifdef constructs to permit programmers to create or use non-portable features.

    You should understand that the Java language can be implemented separately from the other Java components. All early implementations of Java compilers created intermediate code that runs on the Java Virtual Machine; but some vendors are today producing compilers that create executable files for a specific architecture.

    The Java language continues to evolve. Version 1.0 of the language provided a very clean, simple, and robust implementation of object-oriented concepts. In Version 1.1, the most major change was the introduction of Inner Classes. (see sidebar: Inner Classes and MPE). Java's designers have indicated that parameterized types will most likely be added to the language in a future version. On the other hand, the designers insist they do not plan to add operator overloading, an often requested feature that Java's designers feel is error prone and confusing.