Categories: Java

Byte Code in Java

Byte Code:

The 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 to run, i.e, Java programs are compiled, and their byte codes are produced. The byte codes are always the same irrespective of the computer system they are to execute upon.

To understand the byte code, one must be clear about the compilation process.

Ordinary Compilation process:
  • The program or the source code written by a programmer is usually called the source code.
  • This source code needs to be converted into a machine language code, which a computer can easily understand.
  • The process of converting a source code into machine language code is called compilation.
  • The converted machine code depends a lot on the platform it is executing upon, i.e, the resultant machine code is called native executable code.
  • Instead of using a compiler, one can use an interpreter, which translates the code instruction-by-instruction.

here, the first diagram is the ordinary compilation process, whereas, the second diagram represents Java compilation producing the bytecode.

Java Compilation:
  • Contrary to ordinary compilation, the Java compiler does not produce native executable code for a particular machine. Instead, it produces a special format called byte code.
  • The Java byte code looks a lot like machine language, but unlike machine language, Java byte code is the same on every platform.
  • However, the Java programs that have been compiled into byte code still need an interpreter to execute them on any given platform.
  • The interpreter reads the byte code and translates it into the native language of the host machine.
  • Since byte code is completely platform-independent, only a few native libraries need to be ported t get Java to run on a new computer or operating system.

Note: also read about the Setting CLASSPATH in Java

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

2 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

1 year ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

1 year ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

1 year ago