Loading, please wait...

A to Z Full Forms and Acronyms

What is Bytecode in Java?

Jun 13, 2020 #Java#JavaBytecode, 17544 Views
Brief about Bytecode

What is Bytecode in Java and it’s working?

Bytecode in Java is an intermediate machine-independent code. It is a set of instructions for Java Virtual Machine and it acts pretty similar to the assembler in C++. In general, bytecode is a code that lies between low-level and high-level language. The bytecode is not processed by the processor. It is processed by the Java Virtual Machine (JVM). The job of the JVM is to call all the required resources to compile the Java program and make the bytecode independent. It is the biggest reason why java is known as a platform-independent language. The intermediate code can run on any of the platforms such as Windows, macOS, and Linux.

Working of Java Bytecode

Program: Program is a .java file. It consists of the code that you have written.

Compiler: Compiler complies the .java file and generate .class file.

Bytecode: The .class file contains the bytecode. Now, we can run the .class file in any of the other platforms.

JVM: JVM runs the bytecode without considering a processor.

Machine Code: Now, the machine generates its own machine code in which the byte code is running. That means, its own machine-dependent code to run the .java file.

The only essential requirement for running the bytecode is the installation of basic java in any platform.

Advantages of bytecode:

  • It helps in achieving the platform-independent goal with the help of bytecode.
  • The set of instructions for JVM may differ from one system to another but all systems can run the bytecode.
  • Bytecode runs only when the interpreter is available.
  • It runs on the Java virtual machine only.
  • It gives flexibility by giving a quote ‘Write code once, run code anywhere’.
  • It also saves a lot of time for a programmer.
  • It is of low cost however it gives a high return.

Disadvantages of Bytecode:

  • It takes more time to run the bytecode that the machine code which is machine specific.
  • It is difficult to use some platform-specific features because java is platform-independent.
  • Mandatory installation of Java interpreter to run the byte code.

 

A to Z Full Forms and Acronyms

Related Article