Home > Articles > Programming > Java

Java Reference Guide

Hosted by

Toggle Open Guide Table of ContentsGuide Contents

Close Table of ContentsGuide Contents

Close Table of Contents

What Is Java?

Last updated Mar 14, 2003.

In 1995, Sun Microsystems made the first public version of Java available. It defined Java as having the following attribute:

  • Java is simple. That simplicity derives from syntax similar to C/C++ and the omission of complex C/C++ features such as multiple implementation inheritance, pointers, and operator overloading.
  • Java is object-oriented. Java’s object-oriented nature encourages a developer to think in terms of classes and objects rather than separate code and data. That class/object focus results in code that is easier to write, easier to maintain, and easier to reuse.
  • Java is network-savvy. A TCP/IP library simplifies the development of programs that communicate with HTTP, FTP, and other TCP/IP network processes. Furthermore, the library’s use of the same stream-oriented mechanism for communicating with remote network processes that file-oriented code uses to communicate with files on a computer’s local hard drive helps a developer write network code faster.
  • Java is interpreted. Java’s compiler translates source code into class files of bytecode instructions. A virtual machine examines each instruction and uses that instruction’s meaning to execute an equivalent sequence of platform-dependent instructions. Interpretation speeds up the development process and simplifies debugging.
  • Java is robust. Errant programs do not crash the virtual machine or corrupt the underlying (native) platform. Robustness is achieved, in part, by not supporting C/C++ pointers, by providing a garbage collector to automatically free up dynamically allocated memory (instead of forcing the developer to accomplish that task), by performing strict compile-time/runtime type checking, and by providing true arrays with bounds checking.
  • Java is secure. Java’s "sandbox" security model identifies sensitive operations (such as file I/O) that a malicious program can exploit to harm the native platform, and provides a mechanism for allowing or preventing access to those operations.
  • Java is architecture-neutral. A compiled Java program’s bytecode instructions target a generic virtual machine instead of a specific platform. Because each platform-specific virtual machine implementation supplies a consistent interface to the bytecodes, the same Java program runs on diverse platforms (via their virtual machines).
  • Java is portable. Portability is achieved through architecture neutrality and through a strict definition of the language (which permits no implementation-dependent features). For example, Java’s integer primitive type always means a signed 2’s complement 32-bit integer. In contrast, the C/C++ integer type can be unsigned, and its size varies according to a platform’s register size (typically 32 bits or 64 bits).
  • Java is high-performance. Many virtual machines use a just-in-time (JIT) compiler to dynamically compile a program’s bytecode instructions into platform-specific instructions (which execute faster than bytecodes) as the program runs.
  • Java is multithreaded. Support for threads is built into the language via thread-synchronization primitives. There is also a thread library.
  • Java is dynamic. Java’s use of an interface type to distinguish between what a program must do and how that task gets accomplished helps Java adapt to a continually evolving environment, and makes it easier for vendors to modify Java libraries without breaking program code that uses those libraries.

The above definition implies that Java is not your average computer language. Unlike many computer languages, a Java compiler doesn’t translate correct source code (based on a language specification’s syntax and semantics) to equivalent executable code that runs directly on Microsoft Windows/Intel, Sun Solaris/SPARC, or another platform (an operating system and hardware architecture combination). Instead, Java’s compiler translates correct source code to executable code that runs indirectly on a native platform via a virtual machine (a software representation of a hypothetical computer). The virtual machine presents a well-defined interface to a Java program’s bytecode instructions (operation codes and operands that have meaning to the virtual machine) and situates between a Java program’s bytecodes and the native platform.

Initially these goals were ambitious and required developers to spend a significant amount of time testing and debugging their applications running in different virtual machines on different operating systems, but as time moved forward, so did Java. Today, moving between modern Java virtual machines, even from different vendors, is mostly transparent. No longer do you have to think about if your application will run on Linux or Windows, if you choose to use Java you get both for free, plus Macintosh, Sun, AIX, HP-UX, and any other operating system for which there is a Java virtual machine.

The History of Java

Java’s abstraction of the underlying operating system, and hence the underlying network infrastructure, can only be appreciated after a brief history lesson about how Java came to be.

In 1991, a research group at Sun Microsystems, as part of their "Green" project, was working to develop 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 could communication with one another.

The first prototype that Sun Microsystems developed was a device called the Star7 — a device, similar to a remote control that could communicate with other Star7 devices. Now, the initial intent was to use C++ to control the Star7, but as the result of frustration with C++, James Gosling, a member of the Green project, developed a new language, called Oak, to control the Star7. Why Oak you ask? Well, it is pretty technical, but here goes: rumor has it that the title came from a tree that James could see out of his window while developing the language. Sun later replaced the name Oak with Java because they found that Oak was already being used.

Anyway, as a result of Oak, or Java, being designed to run on small appliances, the language had certain inherent benefits to it:

  • It had to be small to run on the limited memory of small appliances
  • It had to be efficient and reliable enough to function as a small appliance — we are all used to crashes using computers, but what if your microwave oven changed its power setting and cause your popcorn to catch fire?
  • It had to be portable to run on different pieces of hardware

So what happened to Java after that? After graduating from the Green project, Java was used to create one of the earliest Web Browsers in 1994, called HotJava, but Java came alive however, in 1995 when Netscape licensed the Java programming language and included support for it in its Navigator product.

In 1997 Sun released the Servlet API that revolutionized server-side web development 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 we have seen enterprise Java flourish and evolve to the current Java 5, Enterprise Edition, and we have seen hoards of open source and close source communities evolve.

The Power of Java

The Java syntax is easy to learn because it resembles C++, its object-oriented foundation makes it intuitive, and its early beginnings in driving communication between devices makes network programming a breeze, but what makes Java truly powerful is its community. One thing that I have always told my students is that before you write any code, look and see if someone has already written the code for you. As you peruse through the Java Reference Guide, you’ll discover technologies like Struts (a Web framework), Hibernate (a persistence engine), Spring (a powerful Inversion-of-Control engine that provides an alternative to enterprise Java), among dozens of other technologies. The Java community has come together in a communal effort to build the majority of technologies you need to build enterprise applications. This enables you to focus on solving your business problems and not on building application infrastructure.

The best sources to discover these technologies are (1) Sourceforge.net and (2) Apache.org, in which most Java projects are delegated to jakarta.apache.org. So the next time you are thinking of building a cache or a connection pool or a web or EJB container, it might be better to check these web sites before hand!

To help drive innovation, Java has a Java Community Process (JCP) through which standards can be defined and accepted by the community. The JCP has seen the inception of a plethora of new technologies and has provided a medium for interested parties to provide feedback and shape the direction of new technologies.

Summary

Java is a feature-rich programming language with a robust set of inherent functionality to empower beginners through experts to build top-quality applications. As a result, most colleges have moved their programming curriculum to Java. But the thing that makes Java great is its community: a group of individuals dedicated to making your job easier. And as such, the Java community projects allow you to focus on solving your business problems rather than spending most of your time building an infrastructure to support your application. If you’re new to programming or you’ve been programming for decades, Java can not only make you more productive, but can help you enjoy programming!