Portable

How java is Considered as Platform Independent and Portable ?

In this tutorial we have covered step by step discussion about –
  1. Which features makes java Platform Independent ?
  2. Why Java is Platform Independent ?
  3. Why Java is considered as Secure and Portable Language ?



A. Java is considered as Portable because –

Java is Considered as Platform independent because of many different reasons which are listed below –
  1. Output of a Java compiler is Non Executable Code i.e Bytecode.
  2. Bytecode is a highly optimized set of instructions
  3. Bytecode is executed by Java run-time system, which is called the Java Virtual Machine (JVM).
[box]

Important Note :

As the output of Java Compiler is Non Executable Code we can consider it as Secure (it cannot be used for automated execution of malicious programs).
[/box]
  1. JVM is an interpreter.
  2. JVM accepts Bytecode as input and execute it.
  3. Translating a Java program into bytecode makes it much easier to run a program in a wide variety of environments because only the JVM needs to be implemented for each platform.
  4. For a given System we have Run-time package , once JVM is installed for particular system then any java program can run on it.
  5. However Internal details of  JVM will differ from platform to platformbut still all understand the Same Java Bytecode.

How Java Program is Platform Independent ?
How Java Program is Platform Independent ?

B. Why Java Code is Safe ?

  1. Java program is executed by the JVM.
  2. The JVM prevent java code from generating side effects outside of the system.
  3. Safety is also enhanced by certain restrictions that exist in the Java language.

C. Interpreter are slower than Compiler

Java Code is Executed by JVM (interpreter).Other programming language uses compiler which can create executable code much faster then why we are using Interpreter.
  1. When a program is interpreted, it generally runs slower than the same program would run if compiled to executable code.
  2. In Java Compiler will generate ByteCode which is highly optimized.
  3. Thus running highly optimized code using interpreter makes execution ofjava program faster.

1 comment: