Java · Basics

Introduction to Java

Java is a general-purpose, object-oriented language that runs on the Java Virtual Machine. It powers enterprise systems, Android apps and big-data tools.

Beginner 5 min Lesson 1 of 31Examples target Java 21 LTS (they also run on Java 25).
0/31 in Java
On this page · 5 min · Beginner

In simple words#

Java code is like a film recorded in a universal format (bytecode). Any device with the right player (the JVM) can play it — Windows, Linux or Mac — without re-recording.

JVM
Java Virtual Machine — runs bytecode.
Bytecode
.class files produced by the compiler.
JDK
Development kit: compiler (javac) + tools + JVM.

Learning objectives#

  • Explain how Java code runs
  • Name the JDK, JRE and JVM
  • Write and run Hello World
  • Know where Java is used

Explanation#

You write .java source files; javac compiles them to bytecode (.class files); the JVM runs the bytecode on any operating system.

The JIT (just-in-time) compiler inside the JVM turns hot bytecode into fast machine code while the program runs.

Java is statically typed and object-oriented, with automatic memory management (garbage collection).

Uses: banking and enterprise back ends (Spring Boot), Android apps, big data (Hadoop, Kafka), and tools like IntelliJ IDEA.

Code example: Hello World#

JavaHello.java Illustrative
public class Hello {
    public static void main(String[] args) {
        String name = "Techie Babaji";
        System.out.println("Namaste from Java, " + name + "!");
    }
}


// Compile and run:
//   javac Hello.java      → creates Hello.class (bytecode)
//   java Hello            → the JVM runs it
// Java 11+ can also run a single file directly:  java Hello.java
Expected output
Namaste from Java, Techie Babaji!

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. Every program starts in a class.
  2. main is the entry point the JVM calls.
  3. System.out.println prints a line.
  4. javac compiles; java runs.

Real-world use case#

Most Indian IT services companies and banks run large Java back ends; Java skills open many job opportunities.

Common mistakes#

File name not matching the public class

public class Hello must be in Hello.java.

Missing semicolons or wrong case

Java is case-sensitive: System, not system.

Best practices#

  • Use a current LTS JDK (21 or 25)
  • Use an IDE like IntelliJ IDEA or VS Code
  • Follow naming conventions (PascalCase classes)
  • Practise with small programs daily

Remember this#

.java → javac → .class → JVM.

main(String[] args) is the starting point.

Write once, run anywhere.

Practice exercise#

Your task: Change the program to print your name and city on two lines.

Show solution
Java Illustrative
System.out.println("Name: Asha");
System.out.println("City: Pune");

Mini quiz#

Introduction to Java quizMultiple choice Question 1 of 2

What does javac produce?

Score so far: 0/0

Want more? Practise all Java MCQs · Java interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.