Java Introduction

What Is Java?
Java is a high-level, object-oriented programming language designed to be platform-independent. You write source once; it compiles to bytecode that the Java Virtual Machine (JVM) runs on Windows, Linux, macOS, and more.
Pipeline:
source (.java) → javac → bytecode (.class) → JVM → run
Slogan: Write Once, Run Anywhere
Entry: public static void main(String[] args)
Build: javac HelloWorld.java
Run: java HelloWorld Java powers enterprise backends, Android apps, and cloud services. This page is the gateway to the Java tutorials—strings, patterns, and interview programs have their own pages.
Why Use Java?
James Gosling led Java’s design at Sun Microsystems in the 1990s (first called Oak). It shipped in 1995 with the goal of portable software across devices and operating systems.
| Need | How Java helps |
|---|---|
| Portability | Bytecode runs on any compatible JVM |
| Safer memory use | Garbage collection frees unused objects |
| Large ecosystems | Spring, Android, big-data, and cloud tooling |
| Strong typing | Many mistakes are caught at compile time |
Key milestones
| Milestone | Year | Notes |
|---|---|---|
| Oak / Java started | 1991 | James Gosling, Sun Microsystems |
| Java 1.0 | 1996 | First public JDK |
| Java 8 | 2014 | Lambdas and Streams |
| Java 17 / 21 (LTS) | 2021+ | Modern long-term support releases |
How a Java Program Runs
Java separates your source from the operating system. Keep this pipeline in mind.
| Step | What happens | Tool |
|---|---|---|
| Write | Edit a .java source file | IntelliJ, VS Code, Eclipse… |
| Compile | Source becomes platform-neutral bytecode | javac → .class |
| Run | JVM loads bytecode and executes main | java ClassName |
| Manage memory | Unused objects are collected automatically | Garbage collector |
Cheat sheet — building blocks
| Concept | Role |
|---|---|
| Types & variables | int, double, boolean, String |
| Control flow | if, switch, loops |
| Methods | Reusable logic inside classes |
| Classes & objects | Encapsulation and OOP |
| Collections | ArrayList, HashMap, arrays |
| Exceptions | try / catch error handling |
What Does a Java Program Look Like?
A minimal console program lives in a class whose name matches the filename:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
} | Part | Meaning |
|---|---|
public class HelloWorld | Class definition; file must be HelloWorld.java |
main(String[] args) | Program entry point called by the JVM |
System.out.println | Prints a line to the console |
| Semicolons & braces | End statements; group blocks |
| Case-sensitive | System and system are different |
OpenJDK is the free open-source reference implementation. Install a JDK so you have both javac and java.
Java vs Python
If you know Python, map the ideas like this:
| Python | Java |
|---|---|
print("Hi") | System.out.println("Hi"); |
| Dynamic types | Static types (int, String…) |
| Indentation blocks | Braces { } |
| Usually interpreted | Compile to bytecode, then run on JVM |
def functions | Methods inside a class |
| Script-friendly | Structured for larger applications |
Same idea, two styles
Print a greeting:
print("Hello, World!") public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
} When to choose which
| Prefer Java when… | Prefer Python when… |
|---|---|
| You want compile-time checks and enterprise/Android ecosystems | You want the fastest path to scripts and prototypes |
| Large teams share typed APIs and long-lived services | Data science, automation, or quick experiments |
| You need JVM tooling and strong OOP structure | Your team already standardizes on Python |
Compile and Run Your First Program
Install a JDK, save the hello program as HelloWorld.java, then build and run it from a terminal in that folder.
javac HelloWorld.java
java HelloWorld How It Works
1. Compile. javac reads HelloWorld.java and writes HelloWorld.class bytecode.
2. Run. java HelloWorld starts the JVM with that class (do not type .class).
3. Entry point. The JVM calls main, which prints via System.out.println.
You need a full JDK to compile. Next, practice text handling with Java strings.
Where Is Java Used?
Common workloads where the JVM and Java ecosystem fit well:
| Use case | Why Java fits |
|---|---|
| Enterprise backends | Spring and related stacks for large services |
| Android apps | Long history of Java (and JVM-related) mobile tooling |
| Cloud microservices | Portable JARs run the same way across hosts |
| Big data & streaming | Tools like Kafka and Hadoop are JVM-centered |
| Finance systems | Strong typing and mature libraries for reliability |
| APIs & middleware | Stable runtime for long-lived server processes |
Key Takeaways
- Java is an OOP language that compiles to bytecode for the JVM.
- Pipeline: write →
javac→.class→java. - Start with: a matching class filename and
public static void main. - Portability: the same bytecode can run wherever a compatible JVM exists.
One line: Java compiles to portable bytecode—next, practice with Java strings.
Frequently Asked Questions
Did you know?
Every beginner Java program needs a public class whose name matches the filename, a public static void main(String[] args) method, and statements ending with ;. Compile with javac HelloWorld.java, then run java HelloWorld.
Next: Java Strings
Practice text handling with common Java string methods.
11 people found this page helpful
