Setting up Java for development

To run, build and create Java apps you need to have Java installed on your machine and this page provides a step by step guide to get Java setup on your machine.

If there is anything missing or not clear in this guide, please leave a comment below.

What are we going to install?

Java Runtime Environment

Java Runtime Environment or JRE is responsible for running compiled Java applications such as .JAR files.

Java Development Kit

Java Development Kit or JDK is responsbile for compiling Java application into runnable code. It also provides a series of basic libraries that we can use in Java development.

Installing on Mac

JRE

  1. First you will need to download JRE from here https://www.java.com/en/download/mac_download.jsp
  2. If you followed the Mac download link you should have downloaded the .dmg version. If you haven’t go back to the site and download the .dmg version as it provides an easier installation process.
  3. Open the .dmg and wait for it to mount a disk which contains the JRE installer.
  4. Open the mounted disk and run the installer and follow the instructions through it to install JRE
  5. Once the installation has completed open up a terminal window (Found in /applications/utilities folder) and enter java -version. You should see output similar to this to indicate Java is installed and ready to go:

JRE installed on Mac

You can find more details on the install process here: https://java.com/en/download/help/mac_install.xml

JDK

  1. First you will need to download the Mac OSX version of JDK from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Open the .dmg and wait for it to mount a disk which contains the JDK installer
  3. Open the mounted disk and run the installer and follow the instructions through it to install JDK
  4. Once the installation has completed open up a terminal window (Found in /applications/utilities folder) and enter java -version. You should see output similar to this to indicate Java is installed and ready to go:

JDK installed on Mac

You can find more details on the install process here: https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html

Installing on Windows

JRE

  1. First you will need to download the Windows version of JRE from here: https://www.java.com/en/download/
  2. Once the .exe has been downloaded, run it and follow the instructions
  3. Once the installation has been completed open a command line window (Search for cmd in the Start section) and enter java -version. You should see output similar to this to indicate Java is installed and ready to go:

JRE installed on Windows

JDK

  1. First you will need to download the Windows version of JDK from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Once the .exe has been downloaded, run it and follow the instructions
  3. Once the installtion has completed. Update the PATH so that it contains the path to the ‘bin’ folder of the installed copy of JDK (For example adding C:\Program Files\Java\jdk1.8.0_181\bin). You can find more details on where and how to update your path to point to the bin folder here https://www.java.com/en/download/help/path.xml and here https://www.computerhope.com/issues/ch000549.htm
  4. With the installation complete and the PATH updated, open a command line window (Search for cmd in the Start section) and enter javac -version. You should see output similar to this to indicate Java is installed and ready to go:

JDK installed on Windows

Frequently asked questions

I am receiving issues around installing JRE or JDK

If you are attempting to install this on a work computer, it may be that you don’t have the correct permissions to install either JRE or JDK. Have a conversation with your IT department to see if they can install JRE or JDK for you, or give you the correct permissions to give you the freedom to install. Failing that, for our workshops, consider using a personal machine where you are likely to have the correct permissions.

If the issue isn’t around permission sets, Google the error you are getting and see if sites such as Stack Overflow offer solutions.

When I run java -version / javac -version it tells me it’s not recognised

If you have installed JRE / JDK but are receiving errors in your terminal or command about java or javac not being available it is likely that the environmental variable for your system named PATH is missing details of where your copy of JRE or JDK are installed.

Oracle offer a useful guide on how to update your PATH to add both the JRE and JDK folders are added to your PATH that you can find here: https://www.java.com/en/download/help/path.xml

Comments