Open In App

Byte Code in Java

Last Updated : 19 Oct, 2021
Like Article

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

  • Suppose you are writing your first JAVA program.


/*package whatever //do not write package name here */
class GFG {
    public static void main (String[] args) {


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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads