Setting Up a Java Development Environment on Windows

Matt Speake
Java Easily
Published in
9 min readSep 10, 2021

In this guide, we’re going to give you the low down on how to set up your machine so that you can develop Java programs. Let’s jump in!

Overview

So, from a high level all you need to do is the following:

  1. Download and install the JDK (Java Development Kit) — this is the Java platform itself which contains all the tools you need to be able to write and run Java programs
  2. Set up some environment variables — these let other apps know where yo installed the JDK to and allow Windows to ‘see’ the tools in the JDK so you and other programs can actually use them.
  3. Download and install an IDE (Integrated Development Environment) — this is the ‘proper application’ you’ll use each day which allows you to type in, edit and run your Java programs.

Whether you’re a highly-experienced Java software engineer working at Google, Facebook or Netflix, or you’re a fresh intern starting out in a bank, these are the tools which all professional Java software engineers have to install once, and use every day to code Java.

Instructions

Downloading and Installing the JDK

Step 1: Find out which version of Windows you have

  • Click the Windows Start button, type the first few letters of ‘about’ in the search text box, and click About your PC from the results.
  • From the dialog which appears, you’ll be able to see if you have a 32-bit or 64-bit version of Windows. This will be in the About section, labelled as System Type:

The description might not say explicitly, but use this as a guide to work out which one you have:

Step 2: Download the correct JDK for your Windows version

So now you know if you have a 32-bit or 64-bit version of Windows, you can download the JDK which works on your system (i.e. a 64 bit version won’t run on a 32-bit version of Windows etc.)

  • Go to your favourite web browser (I hope that’s Google Chrome — that’s mine!), and search for “jdk download”, clicking on the first link which appears if it looks like this:

You’ll end up at the Downloads Page for the JDK on Oracle’s website which is https://www.oracle.com/uk/java/technologies/javase-downloads.html at the time this is written, but is subject to change (which is why we get you to look it up through Google instead).

  • Scroll down to the Java SE 8 section (this is the best version for beginners to get started with and is the most popular version currently in industry), and click the JDK Download link:
  • You’ll be taken to the page which shows all the different versions of the JDK that can be downloaded. There are versions here for Linux, Solaris, Mac and — right at the bottom (so scroll down again!) — for Windows:
  • Click the correct version for your system (you’ll know whether to get the 32- or 64-bit version from the earlier step, remember).

NOTE: you’ll need to accept the agreement and have an account on the Oracle website to download; it’s free to create one and simple to do if you don’t — so create one at this step if you need to, then you’ll be able to download the JDK you selected.

Step 3: Install the JDK you just downloaded

  • You can run the installer directly as soon as it has finished downloading (or optionally save the install file first to a directory you want to keep it in and run from there — sometimes it’s nice to keep the installers for applications you install, that’s what I do, but it’s up to you). To do this, click Run. A popup will appear asking if you’re happy for the installer to make changes to your device, click Yes.
  • When you go through the installation wizard at this point, you’ll click Next through each page of the installer with one important exception though: change the JDK install location from this screen by clicking Change:

Change the path to a folder which doesn’t contain any spaces: on my Windows systems, I’ll use something like C:\tools where I place all my development tools into - so you might like to choose something similar:

NOTE: Be sure to note this folder path down as you’ll use it later when setting up the environment variables.

Click OK to confirm this and step through the rest of the installation wizard by clicking Next for each step.

Once you’ve done this, the JDK has been installed on your system!

Setting up the Environment Variables

Next up we need to set up two important environment variables:

  • Go into Windows Explorer by pressing the Windows key and E (Win+E).
  • Right-click on the This PC node in the left-hand navigation pane, and select Properties:
  • Click the Advanced System Settings link:
  • You’re now at the System Properties dialog where you can configure Windows:
  • Click the Environment Variables… button to go to the Environment Variables dialog:

This is the screen where we’ll set up our environment variables.

Step 1: Creating the JAVA_HOME environment variable

  • In the System Variables section, click the New… button.
  • In the pop-up dialog, type the values as follows (adapting the path I have here for the one you noted down when you installed the JDK earlier — if you didn’t do this, you can just flick back to Windows Explorer, navigate to where you downloaded the JDK to, and right-click in the address bar to copy the value, then paste it here instead):
  • Click OK when you’re done, and you’ll now see the value defined in the Environment Variables dialog:

Step 2: Adding the JDK tools to the System Path environment variable

Next, we’ll add the tools in the JDK folder, which are located in the bin subdirectory of this) to our System Path.

  • From the Environment Variables dialog, click the Path entry in the System Variables pane, then click the Edit… button. You’ll be taken to the edit dialog which allows you to add to the environment variable:

What you’re seeing here is a list of locations where Windows will look in to try and find the programs which correspond to the commands you type from a DOS prompt.

What we need to do now then, is make sure that we add the JDK tools directory to the top of this list — so it becomes the first place Windows will look in (and therefore override the current first entry which is where Windows puts a JRE — this will confuse our development environment, so we override it so the JDK tools we downloaded take precedence over anything shipped with Windows itself — as far as Java is concerned that is (don’t worry — it won’t affect anything besides Java!).

  • Click New… and add %JAVA_HOME%\bin - the percentage signs mean "expand to the real value in the environment variable" when Windows looks at it - i.e. it will expand to the actual path you entered before (so this will become something like C:\tools\jdk1.8.0_291\bin when Windows evaluates it when trying to - and successfully being able to - resolve the JDK commands you type in a Dos Prompt).
  • Now click Move Up several times until this newly-created entry is at the top of the list:
  • Now type the following commands to check your setup:

NOTE: all the versions should show the same as the version of the JDK you downloaded — if they do, you’re good to go! Well done! ;)

Downloading and Installing an IDE

Good news! The IDE is the easiest part of the whole process!

NOTE: Even though we do our actual programming inside this application, it was still important to do the other earlier steps though to ensure our development environment was properly configured since the IDE relies on being able to locate the JDK and the tools inside it (e.g. for compiling your Java code (with the javac command, which is the Java compiler) and being able to run it afterwards (with the java command, which is the Java Virtual Machine).

  • Go to the Jetbrains website (Jetbrains is the company which makes the IntelliJ IDEA — this is the IDE we’ll download and install) and click the Download button.
  • Go to click the Other Versions on the left underneath the IDEA logo.

NOTE: We’re going to download an older version — the most recent 2018 version. This may seem strange, but in my opinion it’s easier for beginners. Ironically, Jetbrains added some extra features to try and make it easier for beginners, but I personally think they’re too confusing and therefore the version before they added these changes are better for you, so we’ll download this version.

  • You’ll be taken to the downloads page:
  • Click the link 2018.3.6 — Windows (exe) to download IDEA.
  • Once IDEA has downloaded, click Run, agree to the allow changes dialog (like we did earlier for the JDK install), and just accept all default options and click Next throughout the installation wizard.
  • Once IDEA has installed successfully, you’ll see the success dialog — click Finish to launch IDEA:
  • Select Do Not Import Settings (since you haven’t installed IDEA before), click OK.
  • Select the checkbox to agree to the license agreement, click OK.
  • Now we’re in the customization dialog, so just click Skip remaining and Set Defaults.
  • At this point, you’ll be greeted with the start screen of IDEA:

Well done — you’ve successfully installed IntelliJ IDEA and can now start creating projects and start coding in Java! ;)

Where Next?

If you enjoyed this or prefer to follow along by video, go grab our Java Beginners Starter Kit to jump start your Java journey and learn Java from scratch!

--

--

Matt Speake
Java Easily

Matt Speake is a principal trainer at Java Easily where you can find him writing and recording about all things Java.