Understanding Java Interpreter

In this tutorial, we will learn about java interpreter, and how it works. And also we will understand how a java interpreter is different from a compiler.
Java Interpreter is a system software which implements the Java Virtual Machine(JVM). It is used to convert high-level language to machine level language, so that an operating system can easily understand.
Now let’s see how a java interpreter works:

  1. Java Virtual Machine (JVM) helps to convert the java code into machine language by using Java interpreter.
  2. JVM loads the Java class file and interprets the compiled byte-code.
  3. The interpreter can work as a specialized compiler which supports just-in-time (JIT) compilation which converts a bytecode into native machine instructions.

Considering the following example to see how an interpreter loads a Java program.

java College
java com.web.college.Student

In the first command, College is the class name.
In second command, com.web.college is the name in which the Student class is stored.
Once the class is loaded, the execution starts from the main() method. JVM searches for the main() method and once it founds it, the interpreter invokes the main() method. After executing it, additional threads, and references other class.

Features of Java Interpreter

  • Portability
  • Interpreted
  • Robust
  • Secure
  • Multithreaded

Finally, let’s see how a java interpreter is different from compiler.

  1. Interpreter translates the code instruction by instruction, whereas compiler translates the entire program at once.
  2. Compiler shows all errors at once at the end of compilation, Interpreter doesn’t.
  3. Interpreter takes less time whereas compiler requires more time to compile the code.
  4. Interpreter doesn’t generate intermediate object code,compiler does.
  5. Interpreter execution is slower when compared to compiler.

 

Leave a Comment

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

Scroll to Top