Open In App

Byte Code in Java

Byte Code

Byte Code can be defined as an intermediate code generated by the compiler after the compilation of source code(JAVA Program). This intermediate code makes Java a platform-independent language.

How is Byte Code generated?

Compiler converts the source code or the Java program into the Byte Code(or machine code), and secondly, the Interpreter executes the byte code on the system. The Interpreter can also be called JVM(Java Virtual Machine). The byte code is the common piece between the compiler(which creates it) and the Interpreter (which runs it).



Let us look at this phenomenon, step by step






/*package whatever //do not write package name here */
import java.io.*;
  
class GFG {
    public static void main (String[] args) {
        System.out.println("GFG!");
    }
}

Output
GFG!

Whenever we write any program, it is not written in machine code. We write it in a high-level language like JAVA, C++, Python, etc. But the computer understands only the machine code. So when we execute our program, it is first converted into machine code or Byte code by the compiler and then executed by the Interpreter. 

This intermediate code or the byte can run on any platform making, JAVA a platform-independent language.

Article Tags :