Thursday, 5 December 2013
0 comments

Compilation used to Generate Byte Code in Programming: Introduction to JAVA

Compilation Process

The program or code in java written by the programmer is usually called the Source Code in programming. This source code needs to be converted in to language code, which a computer can easily understand. The process of converting a source code in to machine code, is called compilation. The converted machine code depends a lot on the platform it is executed upon. That means for different platforms different machine code is produced. This resultant machine code is called native executable code.

Compilation used to Generate Byte Code in Programming: Introduction to JAVA

Instead of using a compiler, which translates the program all at once, you can use an interpreter, which translate it instruction-by- instruction, as necessary. In order to execute a program, the interpreter repeatedly reads one instruction from the program, decide what is necessary to carry out that instruction, and then performs the appropriate machine language commands to do so.

Java Compilation

Contrary to ordinary compilers, the Java compiler does not produce native executable code for a particular machine. Instead it produce a special format called byte code.
Java Byte Code is a machine instruction for a Java processor chip called Java virtual machine. The Byte code is independent of the computer system it has run upon.
The Java Byte Code looks a lot like machine language, but unlike machine language Java byte code is exactly the same on every platform. This byte code means the same thing on a Solaris workstation as it does on a Macintosh Power Book or on a Windows Vista running on an Intel Pentium V.

Compilation used to Generate Byte Code in Programming: Introduction to JAVA

However, the Java programs that have been complained in to byte code still need an interpreter to execute then on any given platform. The interpreter reads the byte code and translates it into the native language of the host machine on the fly.

Since the byte code is completely platforms independent, only the interpreter and a few native libraries need to be ported to get Java to run on a new computer or operating system.

Java Virtual Machine with Java Platform


0 comments :

Post a Comment

 
Toggle Footer
Top