Skip to content
PickNTech

Introduction to Java

What Java is, how the JVM runs your code, and writing your first program.

Beginner10 minUpdated 20 Sept 2026

What you’ll learn

  • How Java code becomes a running program
  • The difference between JDK, JRE and JVM
  • The anatomy of a Java class
  • Compiling and running from the terminal

Why Java?

Java has been one of the most used programming languages for over 25 years. It powers banking systems, e-commerce backends, Android apps and most of the big-data ecosystem. Companies choose it because it is stable, fast, strongly typed and has an enormous ecosystem of libraries — Spring Boot being the most famous.

If you want to become a backend or full-stack developer in the enterprise world, Java is one of the safest bets you can make.

How Java runs your code

Java is famous for the promise "write once, run anywhere." That works because Java doesn't compile straight to machine code. Instead:

Hello.java→javac→Hello.class (bytecode)→JVM→Your CPU
Source code is compiled to bytecode, which the JVM executes on any operating system.
  1. You write source code in a .java file.
  2. The compiler (javac) turns it into bytecode — a .class file.
  3. The Java Virtual Machine (JVM) reads that bytecode and runs it, translating hot paths to native machine code on the fly (this is called JIT compilation).

Because every operating system has its own JVM, the same .class file runs on Windows, macOS and Linux.

JDK vs JRE vs JVM

TermWhat it isDo you need it?
JVMThe engine that executes bytecodeAlways (it's inside the others)
JREJVM + the standard librariesTo run Java programs
JDKJRE + developer tools like javacTo write Java programs — install this

Tip

Install a recent LTS (long-term support) JDK such as Java 21 or 25. Distributions like Eclipse Temurin are free and widely used.

Your first program

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

Every piece has a job:

  • public class Hello — all Java code lives inside a class. The file name must match the public class name.
  • public static void main(String[] args) — the entry point. The JVM looks for exactly this method signature.
  • System.out.println(...) — prints a line to the console.
  • Statements end with ; and blocks are wrapped in { }.

Compile and run

javac Hello.java   # produces Hello.class
java Hello         # runs it -> Hello, PickNTech!

Since Java 11 you can also run a single file directly with java Hello.java — handy for quick experiments.

⚡ Try it yourself

Change the program to print your name and the current year on two separate lines. Then remove a semicolon and read the compiler error — learning to read errors is a core skill.

Interview questions

QIs Java compiled or interpreted?+

Both. javac compiles source code to platform-independent bytecode. At runtime the JVM interprets that bytecode and its JIT compiler compiles frequently executed code to native machine code for performance.

QWhat is the difference between the JDK, JRE and JVM?+

The JVM executes bytecode. The JRE is the JVM plus the standard class libraries needed to run programs. The JDK is the JRE plus development tools such as the compiler, debugger and jar.

Key takeaways

  • Java compiles to bytecode that runs on the JVM, which makes it portable.
  • Install the JDK to develop.
  • Every program starts at public static void main(String[] args).

Finished this lesson?

Mark it complete to move forward on your roadmap.