Java - An Object Oriented Language

A few years ago, a new computer programming language was born that took the world by storm. Java, as we know it today, is one of the fastest-growing languages in this planet. Ease of programming makes it a natural choice, but it's platform-independent feature is the biggest selling point. That is architecture-neutral.

Java is Architecture-Neutral

In order to execute a program written in a compilable language like C or C++, the source code must first be compiled into an executable form known as binary code or machine code. Binary code, in essence, is a pattern of 1's and 0's understandable by the underlying hardware architecture of the computer on which the program is intended to run. Even if the original source code is written to be platform-independent - that is, the program does not take advantage of any platform-specific language extensions such as a specific type of file access or graphical user interface (GUI) manipulation - the resultant executable version will nonetheless still be tied to a particular platform's architecture, and can therefore only be run on that architecture. That is, a version of the program compiled for a Sun workstation will not run on a PC, a version compiled for PC will not run on a Mac, and so forth.

In contrast, Java source code is not compiled for a particular platform, but rather into a specific format known as byte code, which happens to be platform independent. That is, no matter whether a Java program is compiled under Sun Solaris, or Windows NT or MacOS, or any other operating system for which a Java compiler is available, the resultant byte code turns out to be the same and hence can run on any computer that supports a Java Virtual Machine (JVM).

The JVM is a special piece of software that knows how to interpret and execute Java byte code. That is, instead of a Java program running directly under control of the operating system the way traditionally compiled programs do, the JVM itself runs under direct control of the operating system and the Java program in turn runs under control of the JVM. The JVM in essence serves as a translator, turning the byte code language into the machine code language that a particular computer can understand.

Java, the Features-rich Programming Language

Java is a very rich language, consisting of dozens of class libraries, hundreds of built-in classes, and literally thousands of operations that can be performed with and by these classes.

James Gisling designed Java with the sole intention of developing robust and elegant software to be used in embedded systems and consumer devices, such as appliances, smart cards, portable gadgets, machinery, automobiles, vending machines, PDAs, Cell phones, entertainment devices, etc. As days went by, with the contributions from many IT professionals, Java has evolved into a mature and all-purpose programming language suitable for using to development of complex and sophisticated enterprise-wide applications.

The Java language is a simple, high-level, distributed, interpreted, robust, and secure language. It is also architecture-neutral, portable, high-performance, multi-threaded, dynamic, buzzword-compliant, general-purpose programming language. Java is an open standard and free. Java is a relatively simple language when compared to languages such as C and C++. It has incorporated many nice features of C and C++ as well as other languages. Java is a strongly typed language. Java is a pure object-oriented language that can be used to design applications for business, engineering, and science. Thus Java has become a common language to facilitate different kinds of computers and microprocessor-based equipments use it to fulfill their assigned tasks efficiently.

Advantages of Java as a programming language.

Java is  heavily Object-Oriented (OO)

As one of the latest OO languages to emerge, the Java language designers at Sun Microsystems had the advantage of seeing what had previously worked well in earlier OO languages and conversely which language features had proven to be the most troublesome. Therefore, Java is actually a hybrid of the best features from leading OO languages such as Eiffel, Smalltalk, and C++, with some extra sizzle thrown in by way of new features. One of the most widely used OO languages, C++, is actually an object-oriented descendant of the non-OO C language. As such, C++ provides a lot of back doors that make it very easy to write decidedly un-OO code. In contrast, Java is object-oriented to its very core. That is, everything in Java is an object.

  • All of our data, with the exception of a few simple basic data types, are objects

  • All of the GUI building blocks - windows, buttons, text input fields, scroll bars, lists, menus, trees, layouts and so on - are objects

  • All functions are attached to objects and there can be no free floating functions as there were in C or C++.

  • Even the main program called as main method can not stand alone in Java and it should be bundled within a class. Thus Java lends itself particularly well to coding applications that uphold the object-oriented paradigm.

quite safe: Java programs are much safer compared to C and C++ as Java has no error-prone pointers. Also array indexes are always checked at runtime. Also memory management is the responsibility of the Java VM, so there should be no problem with memory leaks.

more productive: Java programming has been designed by incorporating the latest OO software engineering results from the ground up. Java standard libraries make heavy use of design patterns for the sake of high flexibility. Java has been blessed with a new type called interface, which helps it to be separated from its classic implementation. Java has done away with easy-to-mistake constructs such as multiple inheritance and operator overloading. Java has language-level support for multiple threads. Thus Java is an elegant and powerful programming language that can be used to develop full-blown, stand-alone applications of the sort we might have alternatively written using C, C++, or Visual Basic.

facilitating Internet programming: Java's network library package contains a wealth of Internet connectivity routines such as URL and URL Connection classes. Java uses Unicode as the character set for supporting the international characters. Java also supports programming for the Internet in the form of platform independent Java applets, which are small interactive programs that can be embedded in a html file to be accessed via the World Wide Web and help to make Web pages cool by adding animation, and other dynamic features. Because user can be surfing the Web with virtually any type of computer, it is particularly important that the byte code which gets downloaded be platform independent. This approach to dynamically distributing application code also proves to be useful for organizations interested in deploying applications via their respective intranets. Thus Java is an ideal language for deploying software over the World Wide Web.

In addition, Java allows loading of Java classes dynamically during program execution. This is a radical change for generations of programmers accustomed to the compile-link-load-run cycle for building and running programs. This dynamic feature, though not new, integrated with Java at the language level takes us forward to new approaches to structuring application functionality. Allowing class loading from arbitrary sources, such as the Web, networked devices and local disk, is a notable advance in object-oriented programming.

Java for Network Applications

Java has been used to create clients and servers for many popular Internet services, including e-mail, chat, and file transfer. Java is capable of listening network connections and responding to those connections. Java network applications can use technologies that are 100% Java and can also use non-Java technologies. Java applications can use network connections to pass data and request services.  Java has come out with Remote Method Invocation (RMI) technology to facilitate those who have been coding using object-oriented methodology.  RMI lets a Java client to work with Java server objects on a remote server just as those objects live locally. If the objects were coded in an another object-oriented language, say C++, then Java network applications can with Common Object Request Broker Architecture (CORBA) to get those services being providied by the C++ server objects.

Java applets can provide an enhanced user interface right inside a Web browser window. Java network-specific APIs make it relatively easy to authenticate people and encrypt information so that sensitive transactions can be handled securely. Chat applications are very popular network applications that allow users to send messages to each other in real-time.  One can even use a microphone and stream audio to other chat room visitors, thanks to another Java technology, the Java Multimedia Framework (JMF).

Internet Relay Chat (IRC) includes the ability to share files between IRC clients. Sharing files between one IRC client and another would  violate an important security restriction imposed on applets as they are not allowed to access a client machine's file system, whereas Java applications can access files on a local machine. Multiplayer games are another popular example of network applications that can be written in Java.

Java for E-commerce Applications

The Java programming language is a good choice for development of e-commerce applications as Java has many feature sets that allow it to be an effective platform for e-commerce. In addition, Sun Microsystems has a strong understanding of the critical business issues necessary to consider for e-business. Another reason that Java is often chosen for e-commerce development is the support for Java in a variety of application servers. Servers such as BEA Web Logic, ATG Dynamo, and IBM Web Sphere each lend their own compelling reasons for using Java technology. Also Java 2 Enterprise Edition (J2EE) has come out with a number of robust technologies and services to boost the development of e-commerce applications through Java. J2EE is a leader among technologies geared towards e-commerce and is, as Sun Microsystems refers to it, "a key piece of the end-to-end Java solution: the technology engine for end-to-end e-commerce". J2EE happens to be a robust collection of exciting technologies that provide a solid solution for building strong, enterprise-level, server-side applications, such as e-commerce applications.

Java Provides 'One Stop Shopping'

With most programming languages, the core language does not automatically provide everything that we will need in order to build an industrial-strength application, with a graphical user interface and access to a database management system. For accomplishing these capabilities, we must typically integrate platform-specific and vendor-specific libraries into our application. But this sort of integration hinders application migration from one platform to another. For instance, suppose we have a GUI-oriented C++ application coded using the Microsoft Foundation Classes (MFC) to be run in Windows OS. There are a few choices including emulators before us if we want this software to run in Sun Solaris machine. But none of them are appealing due to various inherent problems. One of them is that not all library calls for a given platform X necessarily have an equivalent for a target platform Y.

Here again, Java comes to our rescue. The Java language provides an extensive collection of application programming interfaces (APIs) that provide a consistent, platform-independent means of accessing all underlying operating system functions, including GUI rendering and DBMS access. If the built-in Java libraries are used for developing applications, the resultant Java code is truly portable. So, there is no necessity of making any changes to the code if we want to migrate a Java application from one platform to an altogether different platform. We have to simply transfer the byte code for the application to the new platform and the application works elegantly in the new platform if it is fitted with a platform-appropriate Java VM, the new target database management system is Java aware, and no vendor-specific extensions to the Structured Query Language (SQL) were assumed in writing the Java code.

Many Faces of Java

But Java is not only a language. It is a machine architecture, an application environment, a specification and an implementation also.

The Java specification describes the low-level machine machine and instruction set it runs on: a concurrent, abstract stack machine with an architecture and a small byte code instruction set closed tied to the language. In addition to describing an execution engine, the Java specification describes certain machine behaviors: startup, shutdown, and loading.

Modern applications run in rich environments (Unix, Linux), which come with several different libraries (system, GUI, utility etc.) and subsystems. Java, though not an operating system, is substantially becoming an OS by providing a portable and enterprise applications environment by providing basic I/O services, a collection of libraries for various data structures and for string manipulation, GUI classes such as Java AWT and Swing, networking classes, and robust memory management. Also Java comes out with new and novel libraries, features and utilities in each release. JDK 1.2 has 59 packages containing 1,457 classes, implementing 14,618 methods. There are in addition some private classes in JDK 1.2. Thus Java is set firmly to give all that required for a robust application environment. Java in addition has defined simpler environments for use in more constrained applications. They are PersonalJava, EmbeddedJava, JavaCard, JavaTV, and JavaPhone. This list is quietly expanding.

Java development and deployment involves several components. Here is a glossary of Java terminology. The following are Java Development and Runtime Components. Java Compilers including native compilers, Core class libraries, JVM, JIT Compilers, Debuggers, Profilers, Applet Viewers, Documentation Generators, Decompilers, Obfuscators, Optimizers, IDE, GUI Builders, and RAD Tools.

Java is basically a specification. The Java designers have put excellent specification for each of its component. The advantage with this is that any one can create any component of Java without an encumbrances to Sun Microsystems Ltd. Sun has also created a reference implementation of everything in the specification.

Where Java is Used

There are innumerable number of mission-critical complex software applications that needs Java. Java is being used in various operating systems, such as all flavors of Unix, Linux, Macintosh, Windows NT, and Web browsers from Microsoft and Netscape and Opera. Also Java is found in Web Servers, Application Servers, DBMSs, Network computers and appliances. Further on, Television set-top boxes, Smart Cards, Embedded controllers in consumer and industrial devices (printers, cameras, robots), and Jewelry items (rings, wristwatches, money clips with built-in JVMs and a water-proof hardware interface) make use of Java.

The Future of Java

The interpreted nature of the Java language code tends to make it a bit slower than compiled languages because there is an extra processing layer involved when an application executes. However, this difference is noticeable when real-time processing speeds are required, such as satellite tracking systems or flight navigation systems. We often notice the lag when the Web browser download large Java programs and applets and compile them. For traditional information systems applications, that involve a human in the loop, the difference in speed is imperceptible. Also, the speed of the network in the case of distributed applications, the speed of a database management system server if a DBMS is used, and even human think time can cause any JVM's response time delays insignificant by comparison. In addition, each new release of the JVM continues to improve upon the execution efficiency of its predecessors. Lastly, when it comes to large-scale enterprise applications, Java's scalability actually makes it more efficient than traditionally compiled languages in many respects.

The future of Java-enabled seems to be bright. Java is bound to become an integral part of most core database technology, providing a common mechanism to build and deploy applications, as well as program the database itself. Also Java is a good language and platform to further promote the ORB religion. Java also will become the preferred access method for most popular Message-oriented Middleware (MOM) products. Basically, every one is looking to java-tize his or her middleware of choice. Thus Java is morphing into a full-blown, enterprise class, application development and processing environment.

Java has acquired a lot of research attention in almost all the domains and the fields such as modern biology. Java has been blessed with a lot of libraries containing many useful classes and utilities. Above all, Java is evolving very rapidly to meet the many software challenges of future human society.

Click for Java Links

Click for Java XML