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 —
- open Terminal, type
java -version
and follow the prompts - Apple’s Knowledge Base Article
- Adobe’s Knowledge Base Article
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.
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.
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 >
Time to give our project a name. I’m calling mine divot
. More on that
later :). Click Next >
IntelliJ will create a src/
directory for us in our new project. Click
Next >.
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.
You’ll find the JDK in
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
Select the folder and click the glowing Choose button.
Success means we now have an option in our Project JDK: list. Click Next >.
It’s awfully nice of IntelliJ to offer Groovy for our developing endeavors, but we’ll skip it. Click Next >
The project has now loaded and is looking fairly blank.
Compile Something!
Right-click on the src
folder, select New and then Java Class
A dialog box pops up asking you to name your class. I’m going with Test
.
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")
}
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.
Retrospective
In this walk-through, we accomplished a few major things.
- installed Java on OS X Lion
- installed IntelliJ
- pointed IntelliJ to the correct JDK
- created a class, compiled and ran with keyboard shortcuts
Happy refactoring!