1.2. Setup For Java

For the entirety of this course, we will be coding in Java. Besides installing Java on your machine, you must also add some support technologies to allow you to run and edit Java code.

1.2.1. Java Development Kit

Installing Java means downloading a package of software called the Java Development Kit, or JDK, for short. The JDK contains software the tools needed to develop and run Java code, namely the the Java compiler, javac, and the Java Virtual Machine (JVM).

While the compiler is responsible for processing Java code into machine readable code, the JVM allows us to run that code on any computer. These tools together, downloaded as the JDK, give us the means to write, compile, and run Java on our machines.

A step-by-step walk-through of the process:

  1. We write code in Java,

  2. The code is passed through the compiler program,

  3. The compiler translates Java into bytecode, a language readable by the JVM.

  4. In the JVM, bytecode is translated to machine code,

  5. Your computer then reads and executes the machine code.

The JVM gives Java more flexibility than other compiled programming languages because it will translate bytecode into the appropriate machine code, depending on the operating environment.

1.2.2. Install the JDK

Open a terminal window on your machine and enter the following command:

java -version

If the response returns a major version 11 (ie 11.0.0 or higher, but not as high as 12.0.0), you can move on to the section below, Java in the Terminal.

If you do not have Java 11, or the command does not work, you can download it here. The relevant install link for your operating system is on the bottom of the page:

Screenshot of different Java installation options on Oracle's website

The figure above shows options for downloading Java 15. You should download Java 11 from the link above.

  • Mac users: we recommend the .dmg option

  • Windows users: we recommend the .exe option

To install, you must first select Accept License Agreement.

Make note of the location where the Java JDK has been installed on your computer.

  • Mac users: This should be /Library/Java/JavaVirtualMachines.

  • Windows users: This should be in the C: Drive under Program Files

Once you have completed the installation steps, move onto the next section.