The byte code

The bytecode format

Bytecodes are the machine language of the Java virtual machine. When a JVM loads a class file, it gets one stream of bytecodes for each method in the class. The bytecodes streams are stored in the method area of the JVM. The bytecodes for a method are executed when that method is invoked during the course of running the program. They can be executed by intepretation, just-in-time compiling, or any other technique that was chosen by the designer of a particular JVM.
Source Code to Bytecode conversion
A method's bytecode stream is a sequence of instructions for the Java virtual machine. Each instruction consists of a one-byte opcode followed by zero or more operands. The opcode indicates the action to take. If more information is required before the JVM can take the action, that information is encoded into one or more operands that immediately follow the opcode.



Java in order to support security and portability, does not compile the source code to executable code. It is translated into bytecode, which is highly optimized set of instructions designed to be executed by the Java run-time system, which is called Java Virtual Machine (JVM). JVM is an interpreter of bytecode.

Bytecode concept in Java,ByteCode Java,What is Byte Code in Java,ByteCode Java,What is ByteCode in Java,What is Bytecode,What is ByteCode,Java ByteCode, Bytecode

Converting the Java program to bytecode instead of compiled code, offers a great ability to run those programs on multiple platforms. Once we have the run-time package for a given system, then any Java program can run on it. Instead, if Java programs were to be compiled to the native code, then it would be very difficult since the same program has to be compiled for every CPU type. 
Using JVM also offers a protected environment which helps in enhanced safety for the system. This reduces any side effects caused by the programs.

1 comment: