Skip to content
Laviyx Learn

Try

Java course menu

Introduction to Java: What It Is, Where It Is Used, and How It Runs

A beginner-friendly introduction to Java: what the language is, where it is used (Android, backend services, enterprise systems, big data), how the JDK, JVM and bytecode work, how Java compares with C++ and Python, and what you will learn in this course.

Beginner4 min readUpdated
On this page

Java is a general-purpose, object-oriented programming language designed to be reliable, readable and portable. Its famous promise is "write once, run anywhere": the same compiled program runs on Windows, macOS and Linux without changes. For three decades it has been one of the most widely used languages in the world, especially for large business systems and server software.

A first look#

Here is a complete Java program:

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

Every Java program is made of classes, and execution starts in a method called main. You will write and run this program yourself in First Java Program.

Where Java is used#

AreaExamples
Backend and web servicesBanking, e-commerce and booking systems; frameworks such as Spring Boot
Android appsMany Android apps and the Android platform libraries (alongside Kotlin)
Enterprise softwareLarge internal systems at banks, insurers, retailers and governments
Big dataTools such as Apache Hadoop, Kafka, Spark (on the JVM) and Elasticsearch
Developer toolsIntelliJ IDEA, Eclipse, build tools like Maven and Gradle
GamesMinecraft (Java Edition)

Java skills are in demand for backend developer, Android developer and software engineer roles.

How Java runs: bytecode and the JVM#

Java sits between compiled languages like C++ and interpreted languages like Python:

  1. You write source code in a file such as Hello.java.
  2. The compiler (javac) translates it into bytecode (Hello.class), a compact instruction set that is not tied to any particular processor.
  3. The Java Virtual Machine (JVM) runs the bytecode. While running, its just-in-time (JIT) compiler turns frequently used code into fast native machine code.

Because every operating system has its own JVM, the same .class files run everywhere.

You will meet three abbreviations:

NameWhat it is
JVM (Java Virtual Machine)Runs bytecode
JRE (Java Runtime Environment)The JVM plus the standard libraries needed to run programs
JDK (Java Development Kit)The JRE plus development tools such as the javac compiler. This is what you install.

Memory is managed for you#

In Java you create objects with new, but you never free them yourself. The JVM's garbage collector automatically reclaims objects that are no longer used. This removes whole categories of bugs common in C and C++, such as memory leaks from forgotten frees and crashes from using freed memory.

Java compared with other languages#

JavaC++Python
Runs asBytecode on the JVM (JIT-compiled)Native machine codeInterpreted bytecode
TypingStatic (types checked when compiling)StaticDynamic
MemoryGarbage collectedManual / RAIIGarbage collected
SpeedFastVery fastSlower
SyntaxVerbose but clearComplexConcise
Typical useBackends, Android, enterpriseGames, systems, performanceScripting, data, AI

Java's syntax looks like C++ (curly braces, semicolons, if, for), so learning one makes the other much easier.

Java versions#

Java gets a new release every six months, and every two years one becomes a long-term support (LTS) version that companies use for years: Java 8, 11, 17, 21 and 25. This course targets Java 21, and everything shown also works on newer versions. Modern Java has features that make code much shorter than older tutorials suggest, such as var, records, switch expressions and text blocks.

Is Java hard to learn?#

Java asks you to declare types and write a little more code than Python, and every program needs a class. In return, the compiler catches many mistakes before your program runs, and the language is very consistent. Its clear structure is why many universities teach Java as a first language.

What you will learn#

  1. Fundamentals: variables, types, operators and input.
  2. Control flow: if, switch and loops.
  3. Methods: parameters, return values, overloading and recursion.
  4. Arrays and strings, including StringBuilder and wrapper classes.
  5. Object-oriented programming: classes, inheritance, interfaces, records and enums.
  6. The Collections Framework: ArrayList, HashMap, HashSet, queues and sorting.
  7. Advanced Java: exceptions, files, generics, lambdas, streams, threads and modern features.

Key takeaway#

Next, set up Java in Installing Java (JDK).

Finished this lesson?