Byte code Java’s Magic – Java Tutorial


Byte code Java’s Magic – Java Tutorial

Bytecode is an intermediate form of Java programs. Bytecode consists of an optimized set of instructions that are not specific to the processor. Java programs are compiled using the javac compiler to get bytecode.

The bytecode is executed using a Java runtime environment which is called a Java Virtual Machine (JVM). Sometimes JVM is also called an interpreter for bytecode.

The programs that are running on JVM must be compiled into a binary format which is denoted by .class files.

Sometime for ease of distribution multiple class files are packaged into one jar file.

The JVM executes .class or .jar files, by either interpreting it or using a just-in-time compiler (JIT) .

The JIT is used for compiling and not for interpreting the file. It is used in most JVMs today to achieve greater speed.

The bytecode verifier verifies all the bytecode before it is executed. This verification helps to prevent the crashing of the host machine.

Java Program Execution Process

Java Program Execution Process

Components of Java Development Kit (JDK)

The Java Development Kit (JDK) is a collection of tools that are used to develop, compile, and run Java programs. Java Development Kit consists of –

javac – The javac is the Java compiler that translates the Java source code into bytecode form and stores it in a separate class file.

java – The java in the Java interpreter, which interprets the bytecode stored in the class file and executes the program to generate output.

javadoc – The javadocis used to convert the Java source code into HTML document for documentation from source code file.

javah – The javah is used to produce the header files for the use of native methods.

jdb – The jdb is the Java debugger which is used to locate the errors in the program.

appletviewer – The apletviewr is used for executing the Java applet.

Following are the steps that illustrate the execution process of the Java application program

First, user creates the Java source code using any text editor like Notepad, Notepad++ etc.

Next, the source code is compiled using the javac compiler. The javac compiler converts the source program into a class file which consists of the byte code.

The developer can use javadoc tool to create the HTML files that document the source program.

The developer may use javah tool for creating the header files.

Finally, the java tool is used to interpret the class file generated by javac tool in order to produce an executable.

execution process of the Java application program


In this article, we understood Byte code Java’s Magic, execution process, and Components of Java Development Kit (JDK) – Java Tutorial. If you like the tutorial share it with your friends. Like the Facebook page for regular updates and YouTube channel for video tutorials.

Leave a Comment

Your email address will not be published. Required fields are marked *