Introduction to Java, Features & Setup (JDK, JRE, JVM)


Table of Contents

  1. What is Java?
  2. A Brief History of Java
  3. Key Features of Java
  4. Java Terminologies: JDK, JRE, and JVM
  5. Java Compilation & Execution Process
  6. Installing Java (JDK) on Your System
  7. Verifying Java Installation
  8. Writing Your First Java Program
  9. Summary and What’s Next?

1. What is Java?

Java is a high-level, object-oriented, class-based programming language that is designed to have as few implementation dependencies as possible. Developed by James Gosling at Sun Microsystems in 1995 (later acquired by Oracle), Java has become one of the most popular programming languages for building enterprise-scale applications, web backends, Android apps, and more.

Its write once, run anywhere capability makes it platform-independent and ideal for distributed computing.


2. A Brief History of Java

Java was initially developed as part of the Green Project at Sun Microsystems and was originally called Oak. It was later renamed Java after the Java coffee from Indonesia. The first public release was in 1995, and since then, it has gone through multiple versions and updates.

Notable milestones include:

  • Java 1.0 (1995): Initial release
  • Java 5 (2004): Introduced generics, annotations, and enums
  • Java 8 (2014): Lambda expressions, Streams API
  • Java 17 (2021): Long-Term Support (LTS)
  • Java 21 (2023): Latest LTS version (as of this writing)

3. Key Features of Java

  • Platform Independent: Write once, run anywhere (via the JVM)
  • Object-Oriented: Everything is treated as an object
  • Robust: Strong memory management, exception handling
  • Secure: Built-in security features like bytecode verification
  • Multithreaded: Supports concurrent execution of threads
  • High Performance: Just-In-Time (JIT) compiler for faster execution
  • Dynamic and Extensible: Supports loading classes dynamically at runtime
  • Portable: Bytecode can run on any platform with a JVM

4. Java Terminologies: JDK, JRE, JVM

JDK (Java Development Kit)

It is a software development kit that includes tools for developing Java applications:

  • javac (Java compiler)
  • java (Java interpreter)
  • JRE and development tools

JRE (Java Runtime Environment)

It provides the environment required to run Java applications. It contains:

  • JVM
  • Core libraries

Note: JRE does not include development tools like the compiler.

JVM (Java Virtual Machine)

The heart of Java’s platform independence. JVM:

  • Executes the bytecode
  • Provides abstraction from the underlying hardware
  • Is different for every OS but runs the same bytecode

5. Java Compilation & Execution Process

Source Code (.java)

Compilation by javac

Bytecode (.class)

Executed by JVM

This process allows Java code to be platform-independent as the same .class file can run on any OS with the corresponding JVM.


6. Installing Java (JDK) on Your System

For Windows:

  1. Download the JDK from the Oracle website.
  2. Run the installer and follow the setup steps.
  3. Set the JAVA_HOME environment variable.
  4. Add JAVA_HOME\bin to your system PATH.

For macOS:

brew install openjdk

Then link it:

sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

For Linux:

sudo apt update
sudo apt install openjdk-17-jdk

7. Verifying Java Installation

After installation, open your terminal or command prompt and run:

java -version
javac -version

If properly installed, you’ll see version numbers for both.


8. Writing Your First Java Program

Here’s a simple “Hello, World!” in Java:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

To Compile:

javac HelloWorld.java

To Run:

java HelloWorld

9. Summary and What’s Next?

In this module, you learned:

  • What Java is and why it’s popular
  • Java’s platform-independent architecture
  • The difference between JDK, JRE, and JVM
  • How to install Java and run a simple program