What is JVM, JDK and JRE in Java?


What is JVM?

Java Virtual machine (JVM) is the virtual machine that runs the Java bytecodes. You get this bytecode by compiling the .java files into .class files. .class files contain the bytecodes understood by the JVM.

 In the real world, JVM is a specification that provides a runtime environment in which Java bytecode can be executed. Different vendors provide different implementations of this specification. For example, this wiki page lists down different JVM implementations.

Most popular implementation of JVM is Hotspot which is owned and provided by Oracle Corporation. (Previously by Sun Microsystems, Inc.).

JVM delivers the optimal performance for Java applications using many advanced techniques, incorporating a state-of-the-art memory model, garbage collector, and adaptive optimizer.

JVM comes in two different flavors – client and server. Although the Server and the Client VMs are similar, the Server VM has been specially tuned to maximize peak operating speed. It is intended for executing long-running server applications, which need the fastest possible operating speed more than a fast start-up time or smaller runtime memory footprint. Developers can choose which system they want by specifying -client or -server.The JVM is called virtual because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and the operating system is a cornerstone of the write-once-run-anywhere value of Java programs.

What is JRE?

The Java Runtime Environment (JRE) is a software package which bundles the libraries (jars) and the Java Virtual Machine, and other components to run applications written in the Java. JVM is just a part of JRE distributions.

To execute any Java application, you need JRE installed in the machine. It’s minimum requirement to execute Java applications on any machine.

JRE bundles the following components –

1.       DLL files used by the Java HotSpot Client Virtual Machine.

2.       DLL files used by the Java HotSpot Server Virtual Machine.

3.       Code librariesproperty settings, and resource files used by the Java runtime environment. e.g. rt.jar and charsets.jar.

4.       Java extension files such as localedata.jar.

5.       Contains files used for security management. These include the security policy (java.policy) and security properties (java.security) files.

6.       Jar files containing support classes for applets.

7.       Contains TrueType font files for use by the platform.

JREs can be downloaded as part of JDKs or you can download them separately. JREs are platform dependent. It means that based on the type of machine (OS and architecture), you will have to select the JRE bundle to import and install.

For example, you cannot install a 64-bit JRE distribution on 32-bit machine. Similarly, JRE distribution for Windows will not work in Linux; and vice-versa.

 What is JDK?

JDK is a superset of JRE. JDK contains everything that JRE has along with development tools for developing, debugging, and monitoring Java applications. You need JDK when you need to develop Java applications.

Few important components shipped with JDKs are as follows:

·         appletviewer – this tool can be used to run and debug Java applets without a web browser

·         apt – the annotation-processing tool

·         extcheck – a utility that detects JAR file conflicts

·         javadoc – the documentation generator, which automatically generates documentation from source code comments

·         jar – the archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files

·         jarsigner – the jar signing and verification tool

·         javap – the class file disassembler

·         javaws – the Java Web Start launcher for JNLP applications

·         JConsole – Java Monitoring and Management Console

·         jhat – Java Heap Analysis Tool

·         jrunscript – Java command-line script shell

·         jstack – utility that prints Java stack traces of Java threads

·         keytool – tool for manipulating the keystore

·         policytool – the policy creation and management tool

·         xjc – Part of the Java API for XML Binding (JAXB) API. It accepts an XML schema and generates Java classes

Difference between JDK,JRE and JVM


Comments

Popular posts from this blog

Java Stack and Heap: Java Memory Allocation Lesson.

How To Set Getters And Setters Method In java Using Eclipse?