Quick Index
Overview


The console is the command interpreter of the system. It is the lowest level technique of compiling and running programs. In other words, we are "closest to Java" in the console.

We'll demonstrate the console by example.

Also see opening console and file browser as needed.

Steps


Let's start by creating a directory with any name you like: e.g. "Examples", "Temp", "Scratch", etc (up to you). We'll call it the working directory
C:
 \---Work
     \---Scratch
Open this ZIP file Greeter.zip
Greeter.java
GreeterTester.java
Copy "Greeter.java" and "GreeterTester.java" from the ZIP to your working directory.
C:
 \---Work
     \---Scratch
         Greeter.java
         GreeterTester.java
Open the console window. Also see opening console. Make sure the current directory in the console is the working directory (where the copied files are located). You can change directories using the "cd" command if needed.
C:\Work\Scratch>
In the console:

  • Type the command "javac Greeter.java"
  • Hit the Enter key

Note: This is how to generally compile -- e.g. "javac Person.java", "javac Ball.java", etc.
C:\Work\Scratch>javac Greeter.java

C:\Work\Scratch>
In the console type the command "javac GreeterTester.java"
Hit the Enter key
C:\Work\Scratch>javac GreeterTester.java

C:\Work\Scratch>
  • In the console type the command "dir" and hit Enter (note: on the MAC/unix the command is "ls")
  • We should see the compiled file Greeter.class
  • We should see the compiled file GreeterTester.class

Note that we could also browse this directory in a file browser.
C:\Work\Scratch>
1
dir Volume in drive C is Windows Volume Serial Number is E2BE-184D Directory of C:\Work\Scratch 01/24/2020 12:02 PM <DIR> . 01/24/2020 12:02 PM <DIR> .. 01/24/2020 11:59 AM 429
2
Greeter.class 02/05/2019 09:29 PM 196 Greeter.java 01/24/2020 12:02 PM 699
3
GreeterTester.class 02/05/2019 09:34 PM 1,114 GreeterTester.java 4 File(s) 2,438 bytes 2 Dir(s) 379,765,329,920 bytes free
  • In the console type the command "java GreeterTester" and hit the Enter key
  • The program output

Notes:
  • We use the command "java" rather than "javac"
  • We do not include the file extension for this command. We use "GreeterTester" rather than "GreeterTester.java"
C:\Work\Scratch>
1
java GreeterTester
2
GREETINGS to you from a simple Java program!!