CodeMIRAI
0 XP

Introduction to Java

2 min read 1 runnable example Quiz included

Java was released by Sun Microsystems in 1995 and is now maintained by Oracle and a large open-source community. It's one of the most widely used languages in the world, especially for big business systems.

Where Java is used

ExampleWhere it runs
Androidphone, tablet and TV apps, written in Java or Kotlin on the same platform
Springthe back ends of banks, insurers, airlines and online shops
Hadoopstoring and processing huge data sets, on the Java platform
Kafkastreaming data between systems, on the Java platform
IntelliJ IDEAthe editor many Java developers use, itself written mostly in Java

Games too: Minecraft's original edition is written in Java.

Write once, run anywhere

Java source code is compiled into bytecode, not machine code for one particular processor. Bytecode runs on the Java Virtual Machine (JVM), which exists for Windows, macOS, Linux and more, so the same compiled program runs everywhere.

Hello.javayour sourcejavacHello.classbytecodecompile onceJVMWindowsJVMmacOSJVMLinuxthe same .class file runs on any machine with a JVM
javac turns your code into bytecode once; each operating system's JVM runs that same bytecode. Write once, run anywhere.
Diagram
Main.java  --javac-->  Main.class (bytecode)  --JVM-->  runs on any OS

Your first look

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

The next lesson explains every word. For now, notice that Java is strict and explicit: everything lives inside a class, and every statement ends with a semicolon.

Why learn Java?

  • Strong typing catches many mistakes before the program runs.
  • Object-oriented design scales to very large codebases.
  • Huge job market and a mature ecosystem of libraries and tools.
Finished this lesson?Mark it complete to earn +20 XP and move your progress on.