Skip to content

Information Technology · Ch 2 — Introduction to Programming

Getting Started with Programming Using an IDE

1

Getting Started with Programming Using an IDE

A computer cannot think — it only carries out instructions given to it, exactly and in order. A program is an ordered set of such instructions written to make a computer perform a specific task, and programming is the activity of designing, writing, testing and correcting those instructions. Because a computer's own machine language (strings of 0s and 1s) is almost impossible for people to write directly, we use a high-level programming language whose words and symbols are close to ordinary English and mathematics. In this course the language is Java.

From source code to a running program

The instructions you type in a human-readable language are called source code. Java follows a two-step path from source code to execution:

  1. A compiler (javac) checks your source code for grammar (syntax) mistakes and translates it into an intermediate form called bytecode (a .class file). Bytecode is not tied to any one type of computer.
  2. The Java Virtual Machine (JVM) then reads the bytecode and runs it on the actual machine. Because every computer runs its own JVM, the same bytecode runs everywhere — this is why Java is called platform independent ("write once, run anywhere").

What an IDE gives you

Writing, compiling, running and correcting a program with separate tools is tedious. An Integrated Development Environment (IDE) bundles all of these into one application so you can do everything from a single window. A typical IDE provides:

  • a source-code editor with colour highlighting and auto-indentation,
  • a compiler / build button that turns source code into bytecode,
  • a run button that executes the program and shows its output in a console pane,
  • a debugger to pause a program and inspect it while it runs, and
  • error messages that point to the exact line where something is wrong.

Your first Java program

Every Java program lives inside a class, and execution begins in a special method called main. Here is a complete program that prints one line of text:

public class Welcome {
    public static void main(String[] args) {
        System.out.println("Welcome to programming!");
    }
}
  • public class Welcome names the class; the file must be saved as Welcome.java (the file name matches the public class name).
  • public static void main(String[] args) is the starting point — the JVM always looks for main first.
  • System.out.println(...) prints the text inside the quotes to the screen and then moves to a new line.
  • Every simple statement ends with a semicolon ;, and the code inside { } braces belongs to the block that opens them.

Steps to write, compile and run in an IDE

  1. Create a new file and type the source code, saving it with the same name as the public class and a .java extension.
  2. Press Compile / Build — the IDE runs the compiler. If there are syntax errors, fix the lines it reports and compile again.
  3. Press Run — the IDE hands the bytecode to the JVM and the program's output appears in the console.
  4. If the output is wrong, edit the source, then compile and run again. Programming is naturally an edit → compile → run → check cycle.
Definition 1Program

An ordered set of instructions written in a programming language that tells a computer how to perform a specific task.

Definition 2Source code

The human-readable instructions a programmer types in a high-level language such as Java, saved in a .java file.

Definition 3Compiler (javac)

A tool that checks source code for syntax errors and translates it into bytecode; it does not run the program itself.

Definition 4Bytecode & JVM

Bytecode is the platform-independent .class output of the compiler; the Java Virtual Machine (JVM) reads and executes that bytecode on the actual computer.

Definition 5IDE

An Integrated Development Environment — a single application combining an editor, compiler, runner and debugger so all programming steps happen in one place.