What is Bytecode?

Bytecode enables Java to be a truly object-oriented language. This makes Java different from other languages.
As I mentioned in Features of Java, Bytecode is an intermediate code. In Java, programs are compiled and interpreted.
Firstly, while compiling a program converts the source code into the intermediate code i.e. the bytecode this bytecode is not directly executable by computer.
Secondly, while running the interpreter converts this bytecode into machine code, which contains machine specific commands, which can be executed by the computer.
When you compile the program using syntax: - javac Filename.java.
If the program compiles successfully, Java compiler creates another file named Filename.class, which is bytecode that can be understood by Java virtual machine (in short JVM).
JVM is also java interpreter. It translates bytecode into machine language that is directly executable by local machine. Following syntax does this: -java Filename,
Where java.exe is Java interpreter and Filename is class file name.
Previous
Next Post »