Menu
Courses / Java Basic / Introduction to Java

Introduction to Java

01 / 10 Part of Java Basic

What is Java?


Java is a high-level, class-based, object-oriented programming language originally released by Sun Microsystems in 1995 and now maintained by Oracle. It was designed around one core promise: "Write Once, Run Anywhere" (WORA). Code written in Java is compiled into an intermediate format called bytecode, which can run on any device that has a Java Virtual Machine (JVM) installed — regardless of the underlying operating system or hardware.



Java is used everywhere: Android apps, enterprise backend systems, banking software, e-commerce platforms, big data tools like Hadoop, and even embedded systems. It remains one of the most in-demand languages in the software industry.



Why Learn Java?



       
  • Platform Independent — thanks to the JVM, the same compiled code runs on Windows, macOS, and Linux.

  •    
  • Object-Oriented — everything is modeled around objects and classes, making large codebases easier to organize and maintain.

  •    
  • Strongly Typed — variable types are checked at compile time, catching many bugs before the program even runs.

  •    
  • Huge Ecosystem — a massive standard library plus frameworks like Spring, Hibernate, and Android SDK.

  •    
  • Automatic Memory Management — Java's garbage collector frees you from manually allocating and releasing memory.



How Java Code Runs


Understanding the Java execution pipeline is key to understanding the language itself:




   
       
           
           
       
   
   
       
           
           
       
       
           
           
       
       
           
           
       
   
StepWhat Happens
1. WriteYou write source code in a file ending with .java
2. CompileThe javac compiler converts it into bytecode (.class file)
3. RunThe JVM reads the bytecode and executes it on your machine


Your First Java Program


Every Java application must have at least one class, and execution begins at a special method called main. Here is the classic first program:



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


Let's break this down:



       
  • public class HelloWorld — declares a class named HelloWorld. The file must be saved as HelloWorld.java (the class name and file name must match).

  •    
  • public static void main(String[] args) — the entry point of every Java program. The JVM looks for this exact method signature to start running your code.

  •    
  • System.out.println(...) — prints text to the console, followed by a new line.



Compiling and Running from the Terminal


javac HelloWorld.java   // creates HelloWorld.class
java HelloWorld         // runs the compiled program



    Note: When running with the java command, you do not include the .class extension — just the class name.


Setting Up Your Environment


To start writing Java, you need:



       
  1. A JDK (Java Development Kit) — includes the compiler, JVM, and standard libraries. Download the latest LTS version from Oracle or use OpenJDK.

  2.    
  3. A code editor or IDE — popular choices are IntelliJ IDEA, Eclipse, or VS Code with the Java extension pack.



Key Terms to Remember



   
       
   
   
       
       
       
       
   
TermMeaning
JDKJava Development Kit — tools needed to write and compile Java code
JREJava Runtime Environment — needed to run (but not develop) Java programs
JVMJava Virtual Machine — executes bytecode on a specific platform
BytecodePlatform-independent compiled code produced by javac



    Coming up next: In the next topic, we'll dive into variables, data types, and how Java stores information in memory.