Card 02/ 06

ExampleDifficulty: Beginner1 min

One Command Writes a File, the Other Reads It

A folder with one file in it, and two commands that take it from text to output. What appears on disk between them is the whole story.

bash
$ ls
Hello.java

$ javac Hello.java

$ ls
Hello.class  Hello.java
javac said nothing, and left a second file behind

javac is the first translation. It read the text, checked it, and wrote Hello.class — the bytecode. Silence means it worked; a compiler that has nothing to complain about says nothing.

bash
$ java Hello
Hello

java is the second translation. Notice what it was given: Hello, with no extension and no .class on the end. It takes the name of a class, not the name of a file, and then goes looking for the bytecode that carries it.

That is the pair you will type for the rest of your life, under one build tool or another: one command that produces bytecode and one that runs it.