top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why is JAVA Architectural Neutral ?

0 votes
3,961 views
Why is JAVA Architectural Neutral ?
posted Sep 8, 2014 by Neelam

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

4 Answers

+1 vote

Java application runs the same bytecodes regardless of any environment (Operating System). To enable a Java application to execute anywhere on the network, the compiler generates an architecture-neutral object file format. An architecture-neutral object file format meaning that compiled Java code (bytecode) can run on many processors given the presence of a JVM. The JVM is the main component of making the java a platform independent language. That is the architectural neutral part.

What is JVM
Java Virtual Machine (JVM) is a specification that provides runtime environment in which java bytecode can be executed. As the name implies, the JVM acts as a “virtual” machine or processor. Java's platform independence consists mostly of its Java Virtual Machine (JVM) . JVM makes this possible because it is aware of the specific instruction lengths and other particularities of the platform. The JVM performs following operation:
- Loads code
- Verifies code
- Executes code

In most cases, other programming languages, the compiler produce code for a particular Operating System but the Java compiler produce Bytecode only for a Java Virtual Machine . When you run a Java program, it runs as a thread within the JVM process. It is the JVM's responsibility to load your class files, verify code, interpret them and execute them. When you issue a command like java , the JVM loads the class definition for that particular class and calls the main method of that class.

It is the JVMs responsibility that makes it possible for the same class file to run on any other Operating Systems. The JVM takes your compiled platform-neutral byte code and interprets it to run platform-specific machine code. It can also compile it into native code with a JIT (a just-in-time compiler that compiles and caches your code, usually one method at a time). Thus, it is in the JVM where your code results, if needed, in native Operating System calls. Therefore, in the JVM , your platform-neutral threading code gets turned into platform-specific threading code.

Credit for JVM: http://net-informations.com/java/intro/jvm.htm

answer Mar 6, 2017 by Rahul Kumar
0 votes

In Java you have two step conversion of the high level code (java code) to machine-code. As part of step 1 you convert the code as part of compilation to "binary code format" that's independent of hardware architectures, operating system interfaces, and window systems. Ans as step 2 you use the JVM which read this binary code and convert it to the machine dependent code which means If the JVM is available on a given hardware and software platform, an application written in Java can then execute on that platform without the need to perform any special porting work for that application. That is why we call JAVA language as Architectural Neutral ?

answer Sep 8, 2014 by Salil Agrawal
0 votes

Java is a platform independent language becoz of the bytecode magic of java.
In java, when we execute the source code...it generates the .class file comprising the bytecodes. Bytecodes are easily interpreted by JVM which is available with every type of OS we install. Whereas C and C++ are complied languages which makes them platform dependent.
The source code written in C / C++ gets transformed into an object code which is machine and OS dependent. That's the reason why C and C++ languages are termed as Platform Dependent.

In case of java, after compilation we get byte code instead of native code (like in C and C++). When we will run the byte code, it is converted into native code with the help of JVM and then it will be executed.

answer Sep 8, 2014 by Kali Mishra
0 votes

In java there is both compiler and interpreter. This make java architectural neutral.While both are not present in every language

Compilation is done outside JVM (Java Virtual machine).Compilation means conversion of .java file into .class file. Now .class file will be given to JVM.In JVM there is a class loader subsytem,which performs following function --------

a) Loads .class file into memory
b) Verifies all bytes code of .class file proper or not .
c) Memory is divided into 5 areas
- 1) Method area
- 2) Heap
- 3) Stack
- 4) Register
- 5) native method stack

JVM use both interpreter & JIT which is used to convert byte code into machine code.So that processor will execute JIT is used to speed execution. So because of these it becomes platform independent. So it is called as architectural-neutral...

answer Sep 9, 2014 by anonymous
...