Download Section 1.6. Why Java is Platform Independent?

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
J
A
V
A
T
U
T
O
R
I
A
L
S
C ore Java: C hap t er 1 . In t ro d u ct i o n t o J av a
Section 1.6. Why Java is Platform Independent?
Why it is said that Java program can be written once and execute anywhere. What makes
Java as platform independent and how Java can be executed on any hardware and O/S platform is explained in this section.
W W W. J 4 S C H O O L . C O M
Section 1.6. Why Java is Platform Independent?
Why Java is Platform Independent?
Objective:
Why it is said that Java program can be written once and execute anywhere. What makes
Java as platform independent and how Java can be executed on any hardware and O/S platform is explained in this section.
Overview:
A platform is the hardware or software environment in which the program runs. This platform in real-life is the laptop and the underlying operating system runs on that laptop.
Any program that needs to be executed on a platform must be converted into machine instructions understandable by that platform. When developers write Java programs and compile it, the code is not directly converted into machine instructions but it is compiled into ByteCode.
Ch a p t e r 1 . I n t r od u c tio n to J av a
Core Java
1
Section 1.6. Why Java is Platform Independent?
Bytecode is not machine instructions that any platform like Windows, Mac will understand
it directly. This Bytecode is understood by Java made Virtual machines. Java Virtual Machines (JVM) interprets the Bytecode into machine specific instructions so that platform can
understand its.
Java Virtual Machine (JVM) plays a key role in making the Bytecode understandable to any
underlying platform thus makes the Bytecode platform independent. If JVM are not preinstalled on any operating system then bytecode will fail to execute on that machine.
This makes the Bytecode platform independent and Java Virtual Machine Platform (JVM)
platform dependent.
Java programming language does not dependent on any underlying platform and thus it
makes Java platform independent. That’s why it is said that Java programs are written once
and executed any where.
Summarize:
•
•
•
•
•
•
Java is a platform independent.
Java programs are compiled into Bytecode which are platform independent.
Bytecode are executed on Java Virtual Machines (JVM).
Java Virtual Machine (JVM) is platform dependent.
JVM needs to be pre-installed on the machine for executing java program.
There are different version of JVM available in the market to support variety of platform.
Ch a p t e r 1 . I n t r od u c tio n to J av a
Core Java
2