3 Why is Java Called Platform Independent Language?

In this we talk About:

1) What is Platform In-dependency?
2) How Java became Platform In-dependency Language?

We also talk about:
What is Source Code , Byte Code Executable Code and Really all this codes comes under platform in-dependency or not and we are also highlighting concept like JVM. and features of JVM.

3) Finally Why is Java Called Platform Independent Language?


Source Code: If you are writing any code in any Language like C, C++,  Java, .NET that code is called as Source Code.

If you want to write Source Code in Java we require text editors like Notepad, Eclipse, Edit Plus, Net beans.

We always first start with Notepad.

Suppose we have a file with name "firstDemo.java" in that file we have

class Demo{
}
class A{
}
class B{
}


This is the Source Code and this file is saved in Hard disk or Secondary Memory.

But you cannot run the source code directly you need to convert the source code into executable code.

Now I have different operating systems like Window Os, Linux, MAC Os, Solaris etc.

So we require some programs to run the source code which is called as translators.

Java Provide two types of translators: 1) Compiler
                                                             2) JVM

First we are choosing compiler  because compiler has ability to understand the Source Code.

If you want to communicate with the compiler we require one more program called as "javac" we can also called as Command, Development Tool, Binary File.

Now compiler is communicating with hard disk and loading file "firstDemo.java" from secondary memory to primary memory. And check whether the Source code is comes under Java Grammar Rule or not. Whatever code we are developing Syntatically correct or not then if NOT correct the compiler is giving appropriate errors.

If all things are correct then compiler will generate Byte Code or JVM Understandable code or Intermediate Code.

Who is Create this file?
Automatically compiler is going to create this file. The extension is always ".class".

What is the file Name then?
Whatever the class name we are giving those names are taken as .class file name.

In our example we have 3 classes then for each classes byte code is generated and files are save into hard disk.

Now for executing we need  to convert byte code into executable code for that we have one more translator called as JVM. 

Note: Byte code is platform Independent code.

Two Translators: 
1) Compiler: Source Code to Byte Code. process is called as Compilation Phase.
2) JVM: Byte Code to Executable code.

Now Java is going to communicate with JVM and JVM is going to communicate with byte code file. 
Previous
Next Post »