Lesson 1 of 5 12 min read
What is programming? How programs execute
Understand what a program is, how Java source code is compiled to bytecode, and how the JVM runs it line by line.
In this lesson you will
- Describe a program as a precise list of instructions for a computer
- Explain the journey from source code to bytecode to a running program
- Read and run a minimal Java program
Programs are precise instructions
A program is a list of instructions that a computer follows exactly. Computers are fast but literal: they do precisely what the code says, in order, without guessing what you meant. Programming is the skill of describing a task so clearly that a machine can carry it out.
Every program, from a calculator to a banking app, does three things:
- Takes input — a key press, a file, a form submission or data from another system.
- Processes it — calculates, compares, sorts or transforms the data.
- Produces output — text on screen, a saved file, a web page or a message to another system.
From source code to a running program
You write instructions in a programming language such as Java, Python or JavaScript. This human-readable text is called source code. A computer's processor cannot run Java source directly, so it is translated first.
Java uses two steps:
- Hello.java (source code)
- javac compiler
- Hello.class (bytecode)
- JVM
- Running program
- The compiler (
javac) checks your code for mistakes and translates it into bytecode, stored in a.classfile. - The Java Virtual Machine (JVM) reads the bytecode and runs it on your computer. Because every operating system has its own JVM, the same bytecode runs on Windows, macOS and Linux. This is Java's "write once, run anywhere" idea.
A repeating cycle: Write the code, then Compile with javac, then Run with java, then Check the output, then Fix mistakes, then back to Write the code
Your first Java program
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, DevCrest!");
System.out.println("Programs run from top to bottom.");
}
}Let's walk through it:
public class Hellodeclares a class namedHello. In Java, all code lives inside a class, and the file must be namedHello.java.public static void main(String[] args)is the entry point. When you run the program, the JVM starts here.System.out.println(...)prints a line of text to the console.- Each statement ends with a semicolon
;. Curly braces{ }group statements into blocks.
Running it yourself
Install a Java Development Kit (JDK 21 or newer), save the code as Hello.java, then run these commands in a terminal:
javac Hello.java # compile: creates Hello.class
java Hello # run the bytecode on the JVMSince Java 11 you can also run a single source file directly with java Hello.java, which compiles and runs in one step.
Execution order
Statements inside main run sequentially, top to bottom. Later lessons show how conditions and loops change this order. Reading code in the order the computer executes it is the most important habit a new programmer can build.
Hands-on exercise
Change the program so it prints three lines: your name, the city you live in, and one thing you want to build with code. Compile and run it. Then delete one semicolon, compile again and read the error message carefully. Which line does the compiler point to?
Knowledge check
3 questions • 70% to pass • Practice only, no certificate
Key concepts
- A program is a precise sequence of instructions that takes input, processes it and produces output.
- javac compiles Java source code into bytecode; the JVM runs that bytecode on any operating system.
- Every Java application starts running in the main method.
- Statements run in order, top to bottom, unless code tells the computer otherwise.
