Introduction to Java

Introduction to Java
Java is one of the most widely used programming languages in the world. It is known for its platform independence, security, and robust performance.
1. History and Features of Java
1.1 History of Java
Developed by: James Gosling at Sun Microsystems (1995).
Acquired by: Oracle Corporation (2010).
Originally designed for embedded systems, but became popular for web, mobile, and enterprise applications.
1.2 Features of Java
Feature Description
Platform Independent "Write Once, Run Anywhere" (WORA) using JVM.
Object-Oriented Everything in Java is based on objects and classes.
Robust & Secure Provides memory management & security features.
Multithreaded Supports concurrent execution of multiple tasks.
High Performance Uses Just-In-Time (JIT) compiler for fast execution.
Automatic Memory Management Garbage Collection handles memory automatically.
Extensive Library Support Java provides rich APIs for networking, file handling, database access, etc.
2. Java Virtual Machine (JVM), Java Runtime Environment (JRE), and Java Development Kit (JDK)
2.1 Java Virtual Machine (JVM)
JVM is an interpreter that runs Java bytecode (compiled Java code).
It allows Java programs to be platform-independent.
✅ JVM Responsibilities:
Converts bytecode into machine code.
Manages memory via Garbage Collection.
Provides runtime error handling.
2.2 Java Runtime Environment (JRE)
JRE is required to run Java programs.
It includes:
JVM
Core libraries (Java API)
Supporting files
✅ JRE is used when you only need to run Java applications, not develop them.
2.3 Java Development Kit (JDK)
JDK includes everything in JRE + development tools (compiler, debugger, etc.).
Used by developers to write, compile, and run Java programs.
✅ JDK Components:
Component Description
javac Java compiler (converts .java files to .class files).
java Java application launcher (runs compiled code).
jar Java Archive tool (packages Java classes into .jar files).
jdb Java debugger.
3. Setting Up the Java Development Environment
Step 1: Download and Install JDK
Visit Oracle JDK Download Page.
Download the appropriate JDK version for your operating system.
Install it and set up environment variables.
Step 2: Verify Installation
Open Command Prompt (Windows) / Terminal (Mac/Linux) and run:
java -version
javac -version
java version "17.0.1"
javac 17.0.1
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
javac HelloWorld.java # Compiles the code
java HelloWorld # Runs the compiled program
Date: 2025-03-28 00:00:00.000000