Java Introduction

Beginner
6 min read
Updated: Oct 2026
JVM language

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.

Remember
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.

NeedHow Java helps
PortabilityBytecode runs on any compatible JVM
Safer memory useGarbage collection frees unused objects
Large ecosystemsSpring, Android, big-data, and cloud tooling
Strong typingMany mistakes are caught at compile time

Key milestones

MilestoneYearNotes
Oak / Java started1991James Gosling, Sun Microsystems
Java 1.01996First public JDK
Java 82014Lambdas 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.

StepWhat happensTool
WriteEdit a .java source fileIntelliJ, VS Code, Eclipse…
CompileSource becomes platform-neutral bytecodejavac → .class
RunJVM loads bytecode and executes mainjava ClassName
Manage memoryUnused objects are collected automaticallyGarbage collector

Cheat sheet — building blocks

ConceptRole
Types & variablesint, double, boolean, String
Control flowif, switch, loops
MethodsReusable logic inside classes
Classes & objectsEncapsulation and OOP
CollectionsArrayList, HashMap, arrays
Exceptionstry / catch error handling

What Does a Java Program Look Like?

A minimal console program lives in a class whose name matches the filename:

Java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
PartMeaning
public class HelloWorldClass definition; file must be HelloWorld.java
main(String[] args)Program entry point called by the JVM
System.out.printlnPrints a line to the console
Semicolons & bracesEnd statements; group blocks
Case-sensitiveSystem 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:

PythonJava
print("Hi")System.out.println("Hi");
Dynamic typesStatic types (int, String…)
Indentation blocksBraces { }
Usually interpretedCompile to bytecode, then run on JVM
def functionsMethods inside a class
Script-friendlyStructured for larger applications

Same idea, two styles

Print a greeting:

Python
print("Hello, World!")
Java
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 ecosystemsYou want the fastest path to scripts and prototypes
Large teams share typed APIs and long-lived servicesData science, automation, or quick experiments
You need JVM tooling and strong OOP structureYour 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.

terminal
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 caseWhy Java fits
Enterprise backendsSpring and related stacks for large services
Android appsLong history of Java (and JVM-related) mobile tooling
Cloud microservicesPortable JARs run the same way across hosts
Big data & streamingTools like Kafka and Hadoop are JVM-centered
Finance systemsStrong typing and mature libraries for reliability
APIs & middlewareStable 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

Enterprise backends, Android apps, big-data tools, finance systems, and cloud microservices. Choose Java when you want portable, type-safe OOP with a large ecosystem.
Yes. Java has clear syntax, strong typing, and excellent learning resources. It is more verbose than Python, but that structure teaches solid habits for larger applications.
Install a JDK, save code as HelloWorld.java, compile with javac HelloWorld.java, then run java HelloWorld. The class name must match the filename.
Yes. OpenJDK is the official open-source reference implementation. Distributions such as Temurin and Amazon Corretto are built from or compatible with OpenJDK.
Java is statically typed and compiles to bytecode for the JVM. Python is dynamically typed and usually interpreted. Java catches many errors at compile time; Python is often faster to prototype.
Practice variables, if-else, loops, and methods in small console programs. Then learn classes, arrays, ArrayList, and exception handling. Use the string, pattern, and interview pages on CodeToFun for drills.

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.

Java strings →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful