How to Setup Java and IntelliJ IDEA
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.
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”.
- Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
- At the top of the page you should see a button that looks like this:
If you click on that button it should take you to a page with the current list of Java downloads.
First you’ll need to click the “Accept License Agreement” radio button, then you can select the download that best fits your machine.
- Once you have downloaded the appropriate JDK file, you need to run the installer. To do this double click the file that you downloaded.
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.
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.
- 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.
- Once you’ve downloaded the IntelliJ installer find it in your files and run the program.
This should launch the IntelliJ installer. You should be able to click “next” as all the default settings should work fine for most developers.
- 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.
- 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”.
- 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.
- 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.
- 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”.
This should take you to the Create new Project prompt.
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.
Note that by default the JDK is in Program Files > Java.
- 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.
- 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.
- 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:
Now you have an empty file where you can write, compile and run Java code!