Java Overview

What is Java?

Java is a high-level, object-oriented programming (OOP) language developed by Sun Microsystems (now owned by Oracle Corporation) in 1995. It was designed to be platform-independent, secure, and easy to use. Java has since become one of the most popular programming languages in the world, widely used for developing web, mobile, desktop, and enterprise applications. Java is case sensitive.

Compilation Process

Java source code is written in plain text files with a .java extension. The compilation process of Java involves several steps:

  1. Writing Code: Developers write Java code using a text editor or an Integrated Development Environment (IDE) like Eclipse, IntelliJ IDEA, etc.

  2. Compilation: The Java source code is compiled using the Java compiler (javac) into bytecode. Bytecode is a platform-independent intermediate representation of the program. This bytecode is saved in files with a .class extension.

  3. Bytecode: The generated bytecode contains instructions that can be executed by the Java Virtual Machine (JVM).

Java Virtual Machine (JVM)

The JVM is a crucial component of the Java platform. It's responsible for executing Java bytecode and providing various runtime services. Here's how it works:

  1. Class Loader Subsystem: Loads classes and interfaces as they are referenced by the Java program. It consists of three subsystems: the Bootstrap Class Loader, the Extension Class Loader, and the Application Class Loader.

  2. Runtime Data Area: JVM divides memory into several runtime data areas, including Method Area, Heap, Java Stack, PC Register, and Native Method Stack. These areas are used for different purposes such as storing class metadata, objects, and method invocation records.

  3. Execution Engine: It interprets bytecode or, in some cases, compiles it into native machine code for better performance. The execution engine includes the Just-In-Time (JIT) compiler, which dynamically compiles frequently executed bytecode into native machine code to improve execution speed.

  4. Native Interface: JVM provides a native interface to interact with native libraries and code written in other programming languages like C and C++.

  5. Garbage Collector: Manages the memory used by Java objects. It automatically deallocates memory occupied by objects that are no longer in use, preventing memory leaks and optimizing memory usage.

The JVM is available for different platforms (Windows, Linux, macOS, etc.), allowing Java programs to run on any system that has a compatible JVM installed.

Last updated