Hello guys, I am back with a new blog and in this blog, we are going to talk about some important aspects of Java such as

  • Difference between JDK, JRE, and JVM
  • The Java Compiler
  • Internals of JVM

Let us first start with the differences between JDK, JRE, and JVM.

  • **JDK — **JDK stands for Java Development Kit. It provides a software development environment for developing Java applications. It includes the Java Runtime Environment (JRE), an interpreter (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools required for the development of applications.
  • JRE — JRE stands for Java Runtime Environment. JRE is core libraries plus Java virtual machine. It provides an environment to execute a java application.
  • JVM — JVM stands for Java Virtual Machine. Whenever you execute a program via the java command, it creates a virtual environment in which the program is loaded along with core libraries.

Compilation

The Java Compiler compiles the source files (*.java) into class files. Each class file contains machine-independent byte code, and once compiled, it can be executed on any machine. Therefore class files are platform-independent whereas JVM is platform dependent. The reason behind this is JVM makes use of the internals of the Operating System. That is why we have different setups for different operating systems. The JVM transforms the byte code into machine code or native code.

The compilation of source files involves the following steps

  • **Parse — **Reads source files and then maps the resulting token sequence into the Abstract Syntax Tree. The Abstract Syntax Tree is a tree representation of the abstract syntactic structure of source code. Each node in a tree denotes a construct occurring in the source code. The syntax is “abstract” in the sense that it does not represent every detail appearing in the real syntax, but rather just the structural or content related details

Image for post

  • **Enter — **Enter symbols for the definitions into the symbol table. The Symbol table stores information about various entities such as variable names, function names, objects, classes, interfaces, etc. A symbol table may serve the following purposes

#compilers #jvm #architecture #java

Internals of Compiler and JVM
1.85 GEEK