0% found this document useful (0 votes)
86 views

Java - Platform Independence

Platform independence means software can run on any system without modifications, while cross-platform software runs with the same codebase but potentially different installers on multiple systems. Java aims for platform independence by compiling to portable bytecode for a virtual machine, but still requires different installers for different systems. It uses various techniques like avoiding pointers, garbage collection, strict type checking, and runtime checks to improve robustness compared to C/C++.

Uploaded by

cvelan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Java - Platform Independence

Platform independence means software can run on any system without modifications, while cross-platform software runs with the same codebase but potentially different installers on multiple systems. Java aims for platform independence by compiling to portable bytecode for a virtual machine, but still requires different installers for different systems. It uses various techniques like avoiding pointers, garbage collection, strict type checking, and runtime checks to improve robustness compared to C/C++.

Uploaded by

cvelan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

No Platform-Independence and Cross-platform are not same.

lets have a look at the following explanations to


understand.

Cross-platform software

cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts
that are implemented and inter-operate on multiple computer platforms

It may be divided into two types.

1. One requires individual building or compilation for each platform that it supports,
2. And the other one can be directly run on any platform without special preparation, e.g., software written in an
interpreted language or pre-compiled portable byte code for which the interpreters or run-time packages are
common or standard components of all platforms.
A Multi-platform or cross-platform software: software is available on more than one platforms (operating
systems). This could mean two things -
1. The software is provided with different builds / applications for different platforms [different packages for
windows, this one for linux].
2. The software can be run (with the same download) on multiple platforms but NOT all.

Platform Independent

Software that is platform independent does not rely on any special features of any single platform, or, if it does,
handles those special features such that it can deal with multiple platforms.

Platform Independent software : Platform independent software in its strict sense means –
 Install anywhere and run everywhere – it doesnt matter where you are. Although you may get different
installers (for different platforms), this would be just for users ease. There would be options for you to install
directly from the source code.

------

Java calls the process of going from source files (.java) to .class files compiling. However, the result
can't run on it's own. The result is a preprocessed set of instructions ( p-code ) that the JVM
( interpretor ) runs. JVM stands for Java "Virtual Machine,", the idea being that .class files are machine
code inside the the VM. It's a cute, if confusing, way for Java to obfuscate it's interpreted nature.

Java "write once run anywhere" dream falters in the real world, particularly on the desktop. There's a
reason Java enjoys its greatest popularity in the middle tier, where UI doesn't come into play.

-----

Overall, Java is a small language, closer in size to Pascal or C than Ada or C++.
Java's relatively small size is a powerful argument in its favor as a teaching
language.
Type Checking

Type checking is the process of analysing a program to ensure that the


types of expressions are consistent. For instance if a variable is declared
as being of type int then it should not be assigned a real value (or a string
or any other type). To perform these checks the verifier needs to keep a
record of the type associated with each name and check this type each
time the name is referenced in the program.

Another check which should be made when a variable is declared is that it


is assigned a type which exists. If the programmer declares a variable of a
user defined type, then they must also have defined the type. This check
will also pick up simple typographical errors in type names.

-----

Here are some of the measures that Java uses to achieve robustness:

 No pointers. Although Java uses pointers internally, no pointer operations


are made available to programmers. There are no pointer variables, arrays
can't be manipulated via pointers, and integers can't be converted into
pointers.
 Garbage collection. Thanks to automatic garbage collection, there's no
chance of a program corrupting memory via a dangling pointer.
 Strict type checking. Java's type checking is much stricter than that in C or
C++. In particular, casts are checked at both compile time and run time. As a
bonus, type checking is repeated at link time to detect version errors.
 Run-time error checking. Java performs a number of checks at run time,
including checking that array subscripts are within bounds.

You might also like