Setting up IntelliJ 10.5 on OS X Lion

September 01, 2011

First things first —

  • target developers just getting started with JetBrains IntelliJ IDEA on Mac OS X Lion
  • assume basic knowledge of OS X application installation
  • goal working, compiling, rocking installation of IntelliJ
  • time 20 minutes

I’ve recently upgraded to Lion. Given that my next project is [likely] Java, one of the first things I moved on was setting up my favorite Java IDE: IntelliJ.

Getting Java

As has been noted many times around the web, Java is no longer automatically installed. Fortunately for us, it’s a quick and easy installation. There are already multiple documented ways to go about doing this —

Any of the above will work. We know we’re ready to move on when typing javac -version returns a version number instead of launching an installation prompt as shown below.

01: JDK Installed

Getting IntelliJ IDEA

The folks at JetBrains have really made a name for themselves in the managed code development space. I found out on my last project that ReSharper was absolutely critical to writing good C#. Refactoring ability and keyboard shortcut intuitiveness is second-to-none. It’s much the same with Java, and now that they’ve released an open-source community edition of IntelliJ IDEA, there is every reason to try it out.

Halfway down the IntelliJ page is the download link for Community Edition. Nothing too fancy about this installation process — download it, drag IntelliJ to the Applications folder and launch it. It will take a while to launch; oh, Java.

Creating Your First Project

Now that we have IntelliJ launched, we’re ready to start a new project by clicking on the link in the upper left-hand corner.

02: IntelliJ Launch Screen

Since we’re only interested in verifying our IntelliJ installation works, we’re just going to accept the default of Create a project from scratch and click Next >

03: Start a New Project

Time to give our project a name. I’m calling mine divot. More on that later :). Click Next >

04: Name Your New Project

IntelliJ will create a src/ directory for us in our new project. Click Next >.

05: Create a Src Directory

Locate the JDK

This is the last potentially frustrating part. IntelliJ can’t find the JDK by default. Click the Configure… button on the upper right-hand corner to open a Finder window.

06: Set the JDK!

You’ll find the JDK in

/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

Select the folder and click the glowing Choose button.

07: Locate the JDK

Success means we now have an option in our Project JDK: list. Click Next >.

08: Forge Ahead

It’s awfully nice of IntelliJ to offer Groovy for our developing endeavors, but we’ll skip it. Click Next >

09: Skip Out on Groovy

The project has now loaded and is looking fairly blank.

10: Project Loaded

Compile Something!

Right-click on the src folder, select New and then Java Class

11: Create a Class

A dialog box pops up asking you to name your class. I’m going with Test.

12: Name Your Class

We only need the simplest of methods to make sure we’re in business here. Let’s add a main method to our Test class

public static void main(String[] args) {     
    System.out.println("Hello World") 
}

13: Print Something

You can compile and run this code with three keys — control + shift

  • F10. If all goes well, an output window should appear on the bottom

with our friendly greeting.

14: Success!

Retrospective

In this walk-through, we accomplished a few major things.

  1. installed Java on OS X Lion
  2. installed IntelliJ
  3. pointed IntelliJ to the correct JDK
  4. created a class, compiled and ran with keyboard shortcuts

Happy refactoring!


Profile picture

Written by @sghill, who works on build, automated change, and continuous integration systems.