Select Page

How to Setup Java and IntelliJ IDEA

Coding

How to download and install the Java language on your machine as well as a program that lets you write, compile and run Java code. In this post, I’ll tell you how to install Java and write Java code in the IntelliJ Idea editor.

Download Java

Java is a programming language owned and distributed by Oracle, but you can use it for free! You need to download and install the JDK or “Java Development Kit”.

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. At the top of the page you should see a button that looks like this:

java download image

If you click on that button it should take you to a page with the current list of Java downloads.

java downloads list

First you’ll need to click the “Accept License Agreement” radio button, then you can select the download that best fits your machine.

  1. Once you have downloaded the appropriate JDK file, you need to run the installer. To do this double click the file that you downloaded.

downloaded file

This should launch the JDK installer dialog. It will ask you some questions, but you can just repeatedly click “next” as the default options should work fine for most developers.

jdk install dialog

Download IntelliJ IDEA

There are a number of different editors you can use to write your Java code. For this course we will use IntelliJ IDEA, a free program created and distributed by JetBrains. You are welcome to use any program you prefer.

  1. Go to https://www.jetbrains.com/idea/ to download IntelliJ. If you click on the “download” button it should take you to a part of the page that describes the difference between “Ultimate” and “Community” editions. Make sure you download the community edition as that has more than enough features and is free to use for as long as you like.

intelliJ community edition

  1. Once you’ve downloaded the IntelliJ installer find it in your files and run the program.

intelliJ installer

This should launch the IntelliJ installer. You should be able to click “next” as all the default settings should work fine for most developers.

intelliJ install dialog

  1. After you have fully installed IntelliJ you should open the program. The first time you open IntelliJ there are a few more set up steps you need to do.
  1. First IntelliJ will prompt you to see if you want to include any setting from previous versions, chances are this is your first time using IntelliJ so you should select “no”.

intelliJ settings

  1. Then IntelliJ will ask you to pick a theme. This is completely up to personal preference. You’ll notice that in this course we use the Darcula theme.

theme choice

  1. Then you will be asked if you want to include any additional plugins. You do not need any plugins for this course, so you should be able to just select next and move on from these prompts.

plug ins

  1. Now you should be taken to the IntelliJ editor. It will ask you what you want to do first and you should select “Create New Project”.

intelliJ new project prompt

This should take you to the Create new Project prompt.

intelliJ create new project

Since this is the first time you will be writing Java with IntelliJ you need to configure IntelliJ to know where the JDK you previously downloaded is on your machine. Click the “New…” button next to the drop down and select the location of the JDK on your machine.

add Java sdk

Note that by default the JDK is in Program Files > Java.

  1. Once your JDK is included you can create a new project. In the dialog box once you select “next” you will be taken to a new dialog box that will ask you if you want to create your project using a template. For this course we will not use any templates, so simply click next.

template dialog

  1. The next step in creating a new project is adding the name. IntelliJ will use this name to create a new folder on your computer to hold all the project files.

name your project

  1. Once you have named your project and selected “finish” you have a new, but empty IntelliJ project. To start writing code you’ll need a new Java file. To add a Java file, expand the project folder in your navigation bar on the left, right click on the “src” folder, select “new” and choose “Java Class” like shown below:

new java class

Now you have an empty file where you can write, compile and run Java code!