Introduction to Java Programming
A language named after coffee, built so one compiled program could run on any machine with a JVM.
Walk into any postgraduate school's records office and look at the student files. Every folder uses the same printed form: name, matric number, programme, level. But the ink inside is different in every folder.
One says Aisha, PGD Computer Science, another says Tunde, PGD Computer Science.
The printed form is one thing and the filled-in folders are many things made from it. That small difference is the most important idea in this whole course. By the end of this chapter you'll be able to write the "form" in Java, fill in as many folders as you like, and explain exactly what happens in memory when you do.
First, a quick refresher from Programming I. Programming means writing instructions, in a logical order, that make a computer solve a problem for you. We write those instructions in a high-level language, and something has to turn them into machine code.
There are two ways to do that. An interpreter translates and runs the program one line at a time. A compiler translates the whole program in one go, before it runs.
Java does both, and that is its cleverest trick. The compiler (javac) turns your .java file into bytecode, a .class file written for an imaginary computer. Then the Java Virtual Machine (JVM) on each real computer runs that bytecode.
Windows, Linux and macOS each have their own JVM, but they all understand the same bytecode.
Textbooks list Java's main characteristics, and they're worth knowing as a set. Java is simple (it keeps only the features it needs), object-oriented, platform-independent (portable bytecode), reliable (strong type checking, automatic garbage collection, no raw pointers to corrupt memory), multithreaded (it can do several things at once), and it comes with a rich library of ready-made classes. Each one of these was a fix for something that went wrong with C and C++ on those early TV boxes.
Pause & think
A lab technician emails you Hello.class and you double-click it on your own laptop. It runs, even though you never compiled anything on your machine. Which part of Java made that possible, and which part is doing the work at the moment you click?
📌 If you remember nothing else…
- Programming writes ordered instructions in a high-level language; an interpreter runs them line by line, while a compiler translates the whole program first.
- Java compiles .java source files with javac into portable bytecode (.class), which any platform's JVM can execute.
- Java was designed to be simple, object-oriented, platform-independent, robust, multithreaded and rich in libraries.
Quick check
Did it land?
javac into…javac), standard libraries and the runtime environment needed to develop programs?Spotted a mistake?