Java Magic: Byte Code and JVM


Java / Thursday, July 19th, 2018

Short Notes on Byte Code and JVM( Java Virtual Machine)

Byte code and JVM is the key that allows Java to solve both the security and the portability problems, that the output of a Java compiler is not executable code. Byte Code is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM). That is, in its standard form, the JVM is an interpreter for byte code. This may come as a bit of a surprise. As you know, C++ is compiled to executable code. In fact, most modern languages are designed to be compiled, not interpreted – mostly because of performance concerns. However, the fact that a Java program is executed by the JVM helps to solve the major problems associated with downloading programs over the internet.

byte code and jvm

Flavour of Byte Code and JVM:

Translating a Java program into byte code helps make it much easier to run a program in a wide variety of environments. The reason is straightforward: only the JVM needs to be implemented for each platform. Once the run-time package exists for a given system, any Java program can run on it. Remember, although the details of the JVM will differ from platform to platform, all interpret the Java byte code. If a Java program were compiled to native code, then different versions of the same program would have to exist for each type of CPU connected to the internet. This is, of course, not a feasible solution. Thus, the interpretation of byte code is easiest way to create truly portable programs.

The fact that a Java program is interpreted also helps to make it secure. Because the execution of every Java program is under the control of the JVM, the JVM can contain the program and prevent it from generating side effects outside of the system. Safety is also enhanced by certain restrictions that exist in the Java language. When a program is interpreted, it generally runs substantially slower than it would run if compiled to executable code. However, with Java, the difference between the two is not so great. The use of byte code enables the Java run-time system to execute programs much faster than you might expect.

 

<< Previous     Next>>

;

Leave a Reply

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