100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Java

Introduction to Java Programming

Learn what Java is, why it was created, and how its compile-to-bytecode model enables platform independence, forming the foundation for everything else in this course.

Introduction to JavaBeginner8 min readJul 7, 2026
Analogies

1. Introduction

Java is a general-purpose, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. It is one of the most widely used programming languages in the world, powering everything from Android apps and enterprise backend systems to embedded devices and large-scale distributed systems.

🏏

Cricket analogy: Just as cricket is played the same way from IPL stadiums to backyard tape-ball games, Java's design keeps it usable everywhere from Android apps to embedded devices without changing the core rules.

Unlike languages such as C or C++ that compile directly to machine code for a specific processor, Java takes a two-step approach: source code is first compiled into an intermediate form called bytecode, and that bytecode is then executed by the Java Virtual Machine (JVM). This design is the core reason Java earned the slogan 'Write Once, Run Anywhere' (WORA).

🏏

Cricket analogy: Unlike a pitch groundskeeper who prepares a wicket for one specific stadium, Java first prepares a neutral bytecode pitch that any JVM ground crew, whether in Mumbai or Melbourne, can host a match on.

2. Syntax

Every standalone Java program needs at least one class, and execution begins from a special method called main. The basic skeleton of a Java program looks like this:

🏏

Cricket analogy: Just as every cricket match must start with the toss before any ball is bowled, every standalone Java program must start execution at the main method inside some class.

java
public class HelloWorld {
    public static void main(String[] args) {
        // program execution starts here
    }
}

3. Explanation

Java is often loosely described as an 'interpreted' or a 'compiled' language, but the precise description is: Java is a compiled-then-interpreted language. The javac compiler translates .java source files into .class files containing platform-independent bytecode. This bytecode is not native machine code — it is a set of instructions understood only by the JVM.

🏏

Cricket analogy: Java is like a match played in two stages: javac is the selection committee turning raw talent into a squad list of bytecode, which only the match umpire, the JVM, knows how to interpret on field.

When you run a program, the JVM loads the .class file and executes the bytecode. Modern JVMs use a Just-In-Time (JIT) compiler that translates frequently executed bytecode into native machine code at runtime, giving Java near-native performance while retaining portability. It is the JVM implementation that is platform-specific (there is a different JVM binary for Windows, Linux, macOS, etc.), not the Java source code or the compiled bytecode — this is exactly what makes 'Write Once, Run Anywhere' possible.

🏏

Cricket analogy: The JVM is like the host broadcaster's production truck: different equipment in every country, Windows versus Linux versus macOS, but it reads the same match footage format and, with a JIT-like instant replay system, renders it at near-live speed.

Write Once, Run Anywhere (WORA) means the SAME .class bytecode file can run unmodified on any operating system that has a compatible JVM installed. You do not need to recompile your Java source code for each platform.

Common exam trap: Do NOT say 'Java is a purely interpreted language' or 'Java is a purely compiled language like C++'. The correct, precise answer is that Java is compiled to bytecode by javac, and that bytecode is then interpreted and/or JIT-compiled by the JVM. Getting this half right is a frequent source of lost marks.

4. Example

java
public class Greeting {
    public static void main(String[] args) {
        String message = "Hello, Java World!";
        System.out.println(message);
        System.out.println("This bytecode can run on any OS with a JVM.");
    }
}

5. Output

text
Hello, Java World!
This bytecode can run on any OS with a JVM.

6. Key Takeaways

  • Java is a class-based, object-oriented, general-purpose programming language.
  • Java source code (.java) is compiled by javac into platform-independent bytecode (.class), not directly into machine code.
  • The JVM executes bytecode via interpretation and JIT compilation, which is why Java is best described as compiled-then-interpreted.
  • The JVM itself is platform-specific, but the bytecode it runs is not — this enables 'Write Once, Run Anywhere'.
  • Every standalone Java application requires a main method with the exact signature public static void main(String[] args).

Practice what you learned

Was this page helpful?

Topics covered

#Java#JavaProgrammingStudyNotes#Programming#IntroductionToJavaProgramming#Syntax#Explanation#Example#Output#StudyNotes#SkillVeris