Java is a simple and yet powerful object oriented programming language and it is in many respects similar to C++. Java was given birth at Sun Microsystems, Inc. in 1991. Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. It was developed to provide a platform-independent programming language.
Unlike many other programming languages including C and C++ when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by Java virtual Machine (JVM) on whichever platform it is being run.
Java Virtual Machine
What is the Java Virtual Machine? Why is its role?
Java was designed with a concept of ‘write once and run everywhere’. Java Virtual Machine plays the central role in this concept. The Java Virtual Machine (JVM) is the environment in which Java programs execute. It is a software that is implemented on top of real hardware and operating system.
When Java source code (.java files) is compiled, it is translated into Java bytecodes and then placed into (.class) files. The JVM executes Java bytecodes. So Java bytecodes can be thought of as the machine language of the JVM. A Java virtual machine can either interpret the bytecode one instruction at a time or the bytecode can be compiled further for the real microprocessor using what is called a just-in-time compiler. The JVM must be implemented on a particular platform before compiled Java programs can run on that platform.
Java has powerful features. The following are some of them:-
Java is object oriented
Since Java is an object oriented programming language it has following advantages:
Reusability of Code
Emphasis on data rather than procedure
Data is hidden and cannot be accessed by external functions
Objects can communicate with each other through functions
New data and functions can be easily added
Java is Distributed
With extensive set of routines to handle TCP/IP protocols like HTTP and FTP java can open and access the objects across net via URLs.
Java is Multithreaded
One of the powerful aspects of the Java language is that it allows multiple threads of execution to run concurrently within the same program A single Java program can have many different threads executing independently and continuously. Multiple Java applets can run on the browser at the same time sharing the CPU time.
Java is Secure
Java was designed to allow secure execution of code across network. To make Java secure many of the features of C and C++ were eliminated. Java does not use Pointers. Java programs cannot access arbitrary addresses in memory.
Automatic garbage collection is another great feature of Java with which it prevents inadvertent corruption of memory. Similar to C++, Java has a new operator to allocate memory on the heap for a new object. But it does not use delete operator to free the memory as it is done in C++ to free the memory if the object is no longer needed. It is done automatically with garbage collector.
Application of Java
Java has evolved from a simple language providing interactive dynamic content for web pages to a predominant enterprise-enabled programming language suitable for developing significant and critical applications. Today, Java is used for many types of applications including Web based applications, Financial applications, Gaming applications, embedded systems, Distributed enterprise applications, mobile applications, Image processors, desktop applications and many more.