Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Byte Code in Java

  • Last Updated : 19 Oct, 2021

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).

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

Let us look at this phenomenon, step by step



  • Suppose you are writing your first JAVA program.

Java




/*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!
  • The above-written code is called JAVA source code.
  • The compiler compiles the source code.
  • Finally, Interpreter executes the compiled source code.

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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :