I think most of the people will think in the way that, why Java is? for what Java is?. For all these questions my blog is the answer . actually Java is used for software development and also Java is used for most of the embedding systems like microwave oven , washing machine etc etc.. So for all these Java must support all the environments in all aspects therefore Java is independent .
WHY JAVA IS ?
Java is a technology which provides a platform language and API ( application program interface ).
PLATFORM : platform is a program or software which provides runtime environment for execution of an application .
EXAMPLE : 1.operating systems
OPERATING SYSTEMS : Operating systems itself act as a platform for application which developed by using conventional programming languages . C-lang , C++ are called conventional programming languages .
- Java itself acts as a platform for applications which are developed by using Java language .
- In the industry , languages are classified into two categories based on platforms
a) Platform dependent programming languages
b)Platform independent programming languages
We all know that the Java is a platform independent and C-lang and C++ are platform dependent programming languages . But why ?….. well we will see step by step
C-LANG AND C++ IS PLATFORM DEPENDENT WHY???
Before going into why they are dependent and independent programming languages , we should have a little bit idea on what is going inside the process of compiling and execution . let’s see..
- Usually we write source code ( a code which is written by us in high-level language ) which is not machine understandable . In order to make source code to machine understandable language , we need to compile . Upon compiling the source code , object code is created ( which is nothing but the machine understandable code ) . Now the object code is taken by the linker .
- Now the linker is creating an executable file with respect to the local operating system
- When we are porting the .exe file (executable file ) on different platforms then compiler will ensure executable statements , processor information , as well as operating system information. If these all are same with respect to the previous system then those are executed simply on same type of platform , hence these are platform dependent languages .
BUT, WHEN COMING TO JAVA , IT IS QUITE DIFFERENT :
- Java is a platform independent language , the entire Java program will works on JVM ( Java Virtual Machine ) that is the compiling part and the execution part will do by the JVM within the operating system .
- In simple words JVM holds the responsibility of compiling and executing the Java program that is our source code .And also the JRE ( Java Runtime Environment ) will also holds responsibility of execution of a Java program ( i.e to rum the Java application )in the real time world .
- Therefore, JVM should be in the operating system to compile and to execute the Java program .
Now read this story….
In the past when the Java is going to implement in the real world (i.e in 1991) , the Sun Micro System and Java developers held a meeting with all the operating system vendors ( like Microsoft , UNIX , LINUX , SOLARs etc.) . The main goal of the development of Java is to make platform independent , therefore the Sun Micro Systems and the Java developers requested the operating system vendors to implement their JVM in their respective operating systems , that is , the Java developers and the Sun Micro System requested the Microsoft Windows, LINUX , UNIX etc. to implement their JVM in their respected operating systems to make Java as a platform independent language, therefore in each and every operating system the JVM is inbuilt in nature.That is why Java is platform independent in nature but JVM is dependent in nature.
The above description is shown in the figure below
IN C AND C++ :
Rather than just keeping in mind that Java is independent and c and c++ are dependent languages, you should know how they are independent and dependent languages . I think you people got it why Java is independent and c-lang and c++ is dependent .
INTERVIEW QUESTION :
1. Is JVM is a independent or dependent ?… how ?..and why ?