Lesson Weekend

To get started, we need to install the Java development kit (Java SDK) that allows us to create Java applications and the Java Runtime Environment (JRE) which provides the requirements for executing a Java application. This lesson will walk through recommended steps for installing Java on both Windows and OSX Machines.


Installing Java on OSX

  1. Download and install the Java SDK (Standard Edition Development Kit).

  2. Download and install the Java JRE (Runtime Environment).

Confirmation

To make sure everything is installed correctly, run $ java -version. You should get something like this (your version numbers do not need to match those seen below):

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)


Installing Java on Windows

Read through these steps twice, carefully and thoroughly, before you begin, as fixing installations gone awry is much trickier than getting it right the first time!

  1. Download and install the Java SDK (Standard Edition Development Kit). To select the correct version, you will need to determine whether you are running 32 bit or 64 bit Windows, and this depends on your hardware configuration, specifically your CPU. 64 bit Windows can run 32 bit applications (although not as fast) but you can not run 64 bit applications on 32 bit systems. In order to find out what bit version you are currently running, follow these instructions. Many developer applications come in 32 or 64 bit, so it is worth making a note of what type of system you have for installing other tools in the future (such as PHP, MySQL, etc)

  2. Download and install the Java JRE (Runtime Environment). The Windows x86 version is the 32 bit version, the Windows x64 is the 64 bit version. That's right, you need BOTH downloads.

  3. If you haven't previously installed Git, go to Git. Git BASH is very similar to the terminal at our school computers and is easier to use than the Windows Command Prompt in many cases, although you are welcome to use the Windows Command Prompt, PowerShell, or other command line if you prefer. If you try and execute commands in Git BASH and they fail, test them in PowerShell.

  4. Once you have installed Java, you will want to make sure you can run java commands from the terminal (command line such a s Windows Command Prompt, or Git BASH). In order to do this, you will have to add the path to your Java installation to your PATH variable. This is a system configuration file that lets you use shortcuts to applications in the command line (such as $ javac HelloWorld.java instead of writing C:\Program Files\Java\bin\javac HelloWorld.java or similar). Follow these steps (may vary slightly for windows versions). The correct path for your PATH varies from machine to machine, so do not copy and paste a path you find written out on StackOverflow. Use your machine path instead.

  5. After entering your the path to your java/bin directory correctly into your PATH environment variable, restart your computer. The PATH variable gets loaded on boot, so it will not register any changes until you reboot.

Confirmation

To make sure everything is installed correctly, run $ java -version. You should get something like this (version numbers do not need to be the same):

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

You should now be able to run any Java commands (such as $ javac) from your command line just as you would in the Epicodus classroom.