Monday, November 3, 2008

Java Language

What is Java?

A high-level programming language developed by Sun Microsystems. Java was originally called OAK, and was designed for handheld devices and set-top boxes. Oak was unsuccessful so in 1995 Sun changed the name to Java and modified the language to take advantage of the burgeoning World Wide Web.

Java is an object-oriented language similar to C++, but simplified to eliminate language features that cause common programming errors. Java source code files (files with a .java extension) are compiled into a format called bytecode (files with a .class extension), which can then be executed by a Java interpreter. Compiled Java code can run on most computers because Java interpreters and runtime environments, known as Java Virtual Machines (VMs), exist for most operating systems, including UNIX, the Macintosh OS, and Windows. Bytecode can also be converted directly into machine language instructions by a just-in-time compiler (JIT).

Java is a general purpose programming language with a number of features that make the language well suited for use on the World Wide Web. Small Java applications are called Java applets and can be downloaded from a Web server and run on your computer by a Java-compatible Web browser, such as Netscape Navigator or Microsoft Internet Explorer.

History of Java Language

The Java programming Language evolved from a language named Oak. Oak was developed in the early nineties at Sun Microsystems as a platform-independent language aimed at allowing entertainment appliances such as video game consoles and VCRs to communicate . Oak was first slated to appear in television set-top boxes designed to provide video-on-demand services. Just as the deals with the set-top box manufacturers were falling through, the World Wide Web was coming to life. As Oak’s developers began to recognize this trend, their focus shifted to the Internet and WebRunner, an Oak-enabled browser, was born. Oak’s name was changed to Java and WebRunner became the HotJava web browser. The excitement of the Internet attracted software vendors such that Java development tools from many vendors quickly became available. That same excitement has provided the impetus for a multitude of software developers to discover Java and its many wonderful features.

Features of Java

Object-Oriented - Java is a pure object-oriented language. This means that everything in a Java program is an object and everything is descended from a root object class.

Portable and Platform-Independent - Java compilers do not produce native object code for a particular platform but rather ‘byte code’ instructions for the Java Virtual Machine (JVM). Making Java code work on a particular platform is then simply a matter of writing a byte code interpreter to simulate a JVM. What this all means is that the same compiled byte code will run unmodified on any platform that supports Java.

Dynamically Linked - Java language was designed to adapt to an evolving environment. It is a more dynamic language than C or C++. Java loads in classes as they are needed, even from across a network. This makes an upgrade to software much easier and effectively. Classes in Java also have a run-time representation. In C or C++, you have a pointer to an object but you don't know what type of object it is, there is no way to find out. However, in Java, if a program is handed an object, it can find out what class it belongs to by checking the run-time type information.

Multithreaded - It is not hard to image why multithreading has become a must for a language like Java. An application has to be doing something while waiting for user input; In a GUI-based network application such as a Web browsers, there are usually multiple things going on at the same time. Java provides support for multiple threads of execution that can handle different tasks with a Thread class in the java.lang Package. The thread class supports methods to start a thread, run a thread, stop a thread, and check on the status of a thread . This makes programming in Java with threads much easier than programming in the conventional single-threaded C and C++ style.

Garbage Collection - the process of automatically freeing objects that are no longer referenced by the program. The name "garbage collection" implies that objects no longer needed by the program are "garbage" and can be thrown away. A more accurate and up-to-date metaphor might be "memory recycling." When an object is no longer referenced by the program, the heap space it occupies can be recycled so that the space is made available for subsequent new objects. The garbage collector must somehow determine which objects are no longer referenced by the program and make available the heap space occupied by such unreferenced objects. In the process of freeing unreferenced objects, the garbage collector must run any finalizers of objects being freed.

No comments: