Labs ICT
โญ Pro Login

Introduction to Java

So what exactly is Java? I am glad you asked. Java is a high-level, object-oriented programming language created by James Gosling at Sun Microsystems in 1995. The whole idea behind Java was simple: write code once and run it anywhere. And I am not exaggerating โ€” that single idea changed software development forever.

Before Java, you had to write separate code for Windows, for Mac, for Linux, for every platform you wanted to support. It was a nightmare. Java came along and said, "What if we write the code once and let a special layer handle the differences?"

How Java Actually Works

Here is the thing that confuses a lot of beginners. When you write Java code, your computer does not understand it directly. Instead, here is what happens:

  • You write your Java code in a .java file
  • The compiler (javac) turns it into bytecode (a .class file)
  • The Java Virtual Machine (JVM) reads that bytecode and runs it on your machine

Think of bytecode as a universal language that the JVM understands. And since every platform has its own JVM, your bytecode runs everywhere. Windows JVM? Check. Mac JVM? Check. Linux JVM? Check. One bytecode to rule them all.

Platform Independence

This is the magic of Java. You compile your code once and get a .class file. That file can run on any machine that has a JVM installed. It does not matter if that machine is a Windows laptop, a Mac desktop, a Linux server, or even a Raspberry Pi.

You might hear people say "Java is slow" or "Java is old." Do not believe the hype. Modern Java is incredibly fast. The JVM has been optimized for decades. It uses just-in-time compilation, garbage collection, and all sorts of clever tricks to make your code run efficiently.

And old? Java has been around for a long time, sure. But it has also evolved. Java 8, Java 11, Java 17, Java 21 โ€” each release brings new features. The Java of today is not the Java your parents learned in college.

Java in the Real World

Let me give you a quick example to show you Java running. This program tells you what version of Java you are using โ€” useful when you are setting up your environment.

public class Main {
  public static void main(String[] args) {
    System.out.println(System.getProperty("java.version"));
  }
}

That little program will print your current Java version. It uses the System.getProperty() method to grab system information. See how Java gives you access to the system your code is running on? That is part of what makes it so powerful.

๐Ÿงช Quick Quiz

Who created Java?