“Write once run anywhere” feature of Java makes it platform independent. It allows a Java program to run on any operating system like Windows, Linux, Mac or Solaris.
Java Compiler creates .class file which contains byte code. JVM (Java Virtual Machine) executes byte code into machine code. JVM is a part of JRE (Java Runtime Environment).
It is important to know that JVM is platform dependent, it means a separate JVM is available for each operating system. Different JVM produces different binary code for different operating systems.
In other words, binary code of Linux specific JVM will be different from binary code of MAC and Solaris JVMs.. Every Java program runs within the control of JVM, so it can not go beyond the security constraints defined by the JVM.
This is why Java applications are considered as secured applications over internet. This shows, using byte code and different JVMs for different operating systems Java achieves its platform independence and makes software development easy to run on different platforms.
Robust means reliable. Java compiler checks for possible errors that other languages detect at execution time. Java has eliminated certain types of errorprone programming constructs that are found in other languages.
Java has a runtime exception-handling feature to provide programming support for robustness. Using exception handling mechanism, Java can catch and respond to exceptional situations, so that a program can continue its normal execution.
Java has a strong memory allocation and garbage collection mechanism. It does not support pointers, thereby eliminating the possibilities of overwriting memory and corrupting data.
Java is also an architectural neutral language. In the world of internet, it becomes essential that the applications run easily on different machines with different hardware architecture.
The Java compiler generates an architecture neutral object file format to enable Java applications to execute any machine on the network. This feature of Java has thrived the programming language. Hence, Java was designed to support applications on network.
Security is an important concern. Without some assurance of security, you certainly would not want to download any program from a random site on the net and let it run on your machine. Java implements several security mechanisms to protect your system against harm caused by stray programs.
The platform independence and architecture neutral features of Java make it portable. Java also have the standard size for all data types irrespective of operating system or the processor.
No doubt, programs written in Java are faster than other interpreted languages but they are never as fast as in compiled languages, such as C++. It is because Java is interpreted, i.e., the byte code is not directly executed by the system, it is run through the interpreter.
The new JVM is significantly faster than the earlier one. The new JVM uses the technology known as Just-In-Time compilation(JIT). It converts the byte code into machine code on demand basis.
Sun also introduced the Java HotSpot Performance Engine, which includes a compiler to optimize the frequently used code. It can also be plugged into JVM to boost its performance.
Java is also a multithreaded programming language. Multithreading means a single program having different independent tasks to be performed independently, for example, downloading a video file while playing the video would be considered multithreading.
Multithreading feature is well integrated in Java as compared to other languages.
Multithreading is particularly useful in server applications, a server can serve multiple clients at the same time.
In Java, threads can be created in two ways: by extending Thread class and by implementing Runnable interface. You will study about these methods in detail in Threads chapter.
Java is object oriented programming language. It is centered on creating objects, manipulating objects and making them work together.
Even array of primitive data types are represented in the form of objects. Object oriented programming is better than procedural programming because it provides great flexibility, modularity, clarity and reuseability through its polymorphism and inheritance features.
No doubt, C++ is object oriented language too but it is not fully object oriented as it is structured as well.
Java is fully object oriented language because object is at outermost level of data structure in Java. Even primitive data types can be converted into objects using wrapper classes.
Java is easy to learn because of its simplicity. It is partially modeled on C++, but greatly simplified and improved. Java does not have pointers and multiple inheritance that often make coding complicated.
Java programmers are free from memory management responsibilities because memory allocation and deallocation process is automatically managed by JVM. The clean syntax makes java programs easy to write and read.
In distributed computing, several computers work together on a network. Java is designed to develop applications that make distributed computing easy and efficient. Widely used protocols, like HTTP and FTP are developed in Java. Java programs can call the functions provided by these protocols and can access the files from any remote machine on the internet.