1 Java Interview Question – Java Architecture

/

Ever heard of LVEP? This is easiest way to remember the answer for a popular Java Interview Question – What is JVM or Java Virtual Machine? Undoubtedly this is the favorite question among the interviewers to understand the applicant’s knowledge on Java Architecture

 

So, JVM carries out the following functions in a nutshell:

  • Loads the code
  • Verifies the code
  • Executes the code
  • Provides runtime environment

 

The Java Virtual Machine (JVM)

  • JVM is the center of Java programming language and Java platform. The byte code is converted by the JVM into machine-specific code (also known as object code in other programmer languages)
  • JVM offers garbage collection features, memory management, protection, etc. JVM is platform-independent and using its features we can customize, It offers a virtual interface that is not machine-dependent and is independent of the operating system as well. This JVM platform-independence allows one to build Java programmes on one device and run them on another (WORA-Write-Once-Run-Anywhere) system

 

Follow up Question: What is The Java Runtime Environment (JRE)?

JRE = JVM + library classes.

JDK = JRE + Developer tools

 

Did you think you have to code everything and start building a Java Application from scratch? Think again !! Java has existing class libraries that allow you to use them and not have to reinvent the wheel while writing simple applications!!

These class libraries are part of JRE or Java Runtime Environment!

JRE is the runtime environment needed to execute Java programmes and applications, as the name implies. For efficient execution of Java programmes, JRE consists of Java Virtual Machine (JVM) and binaries and other classes.

JRE is a JDK subset and does not include any tools for development, such as a Java compiler, debugger, etc. Therefore, if your Java applications are being built elsewhere and you just need to run them on your platform, you can install JRE separately. For this you need to install JDK.

As it’s the minimum requirement to run Java programmes on your computer, you need a JRE installed on your machine.

The JRE contains the components below.

  • Code libraries, resource files, and property settings: These include files such as charsets.jar, rt.jar, etc.
  • DLL files: Used by the Java virtual machine hotspot client and virtual machine server.
  • Java extension files: For example, locale specification related files such as localedata.jar
  • Needed files for security management. For eg, java.policy, support classes for java.security applets.
  • True Style font files: The platform typically needs them.
  • You need JRE installed on your machine to execute any application/program written in Java. JRE is based on platforms. This means that you need JRE that is compatible with your O.S and architecture to download and update.

 

What is The Java Development Kit (JDK)?

Getting started with Java! Chances are you will have to start with downloading JDK and setting up environment on your computer.

The central component of every Java environment is this. Along with the Java compiler, Java debugger, and other key classes, JDK includes JRE (Java Runtime Environment). For Java creation, JDK is used as it provides the entire executable and binaries as well as tools needed to compile a Java program and debug it.

 

JDK is a program that is unique to the platform and we will thus provide different JDK installers for each operating system. The following components are found in JDK:

  • JConsole: This is a Console for Java Control and Management.
  • Jar: It’s the archivist. As well as handling Jar files, this tool is used to package similar class libraries into a single Jar file.
  • JarSigner: This method is used to verify and sign a container
  • Javap: This is a file disassembler tool for schools
  • Javaws: Open the Java Web launcher for JNLP applications
  • Jhat: Tool for Java heap analysis
  • Jrunscript: shell with Java command-line script
  • Jstack: A tool used to print Java thread stack traces
  • Javadoc: This creates documents from source code comments automatically
  • Appletviewer: Used without a web browser for applet execution and debugging
  • apt: Processing annotation tool
  • extCheck: Utility for checking container file conflicts
  • Keytool: Keystore can be manipulated using this utility
  • Control Tool: This is a tool to develop and manage policies

 

Garbage collector: As the name implies, Garbage Collector means the discarded material to be collected. Ok this job is accomplished by Garbage Collection in JVM. In the JVM heap space, it monitors each and every object available and removes unwanted artefacts. In two basic steps known as Mark and Sweep, the garbage collector functions:

Mark-this is where the garbage collector defines which and which bits of memory are not in use.

Sweep: during the “mark” process, it removes items found.

Environment for Java Runtime:

JRE software builds a runtime environment in which it is possible to run Java programmes. The JRE is an on-disk system that takes your Java code, combines it with the libraries you need and starts running the JVM. JRE provides the libraries and applications that your Java programmes need to run.

JRE is a part of JDK, but can be separately downloaded.