Getting started with IntelliJ

This tutorial will walk you through the steps to set up and start working with JavaNLP using JetBrains' IntelliJ IDE. The top part has getting started instructions for checking out all of the 2008 JavaNLP reorganization as a multi-module project, including using Java 6 with it on the Mac. Beneath the horizontal rule is older material, some of which is now dated. (The useful older material should be integrated at some point.)

IntelliJ is fast. After using the bloated beast that is Eclipse, using IntelliJ makes my neural receptors hum with delight. Loading up and switching between projects is faster. Setting preferences is faster. Tweaking the classpath, refactoring, searching for references, and generating code coverage reports: all faster. -- macjavadev

Instructions for running IntelliJ on a Mac after the 2008 reorganization

These instructions set me up with the whole of the reorganized JavaNLP, using Java 6 to compile under IntelliJ IDEA 7.0.3 under Mac OS X 10.5. I've now put in JavaNLP IntelliJ module specification files (*.iml) files. I think they may be used when you do the checkout, and so a few of these things you might no longer have to do (let me know if you try this).

  1. If you have an existing JavaNLP checkout and want to use the same path, move or delete it.
  2. Download SoyLatte from here. I installed the 32 bit binary (not enough memory in my Mac for 64 bit to be sensible....) Alternatively, it should also work to install the Apple Java SE 6 preview if you want.
  3. Unpack SoyLatte. I unpacked it in ~/Software, but anywhere should work.
  4. Download IntelliJ from here, if you haven't already. Drag the application to your applications folder.
  5. At some point you'll want to give IntelliJ more memory, so you may as well do it now. edit /Applications/IntelliJ IDEA 7.0.3.app/Contents/Info.plist and change the line:
    <string>-Xms16m -Xmx256m -XX:MaxPermSize=120m -Xbootclasspath/p:../lib/boot.jar -ea</string>
    to perhaps
    <string>-Xms32m -Xmx320m -XX:MaxPermSize=150m -Xbootclasspath/p:../lib/boot.jar -ea</string>
  6. Run IntelliJ. If you have an open project, do File | Close Project.
  7. From the "Quick start" page that appears when no project is open, choose Check out from Version Control | Subversion. If you haven't done this before, press the + sign and add the path svn+ssh://jacob.stanford.edu/u/nlp/svnroot .
  8. Expand the tree list triangle down to see trunk, and then again to see javanlp. Click on javanlp, and then press Checkout.
  9. Choose a local Destination directory. I choose /Users/manning/javanlp. Have it check out recursively. Sit back and wait a while.
  10. Say Yes when asked if you would like to create an IntelliJ IDEA project for the sources you checked out.
  11. Choose create Java project from existing sources. Call it javanlp. Take all the source files it has found. Take the libraries it finds. Except rename lib1 as mtlib (select and click on the pencil button). Take the Modules it finds. Except rename Test1 as RTETest. Finish. Wait again.
  12. Open up IntelliJ IDEA | Preferences.... Click on Project Settings. Under Project JDK, click New. Choose JSDK. Navigate to the one you installed and select it (the root directory). Choose OK. It will show up as 1.6 (1.6.0_03-p3) in the combobox. Choose 5.0 as the project language level. For Project compiler output, I changed out to classes, but whatever.
  13. In the same preferences window, under Project Settings, choose Modules, and then choose Core and then choose Dependencies. Remove the two libraries from mt/lib (fastutil-5.0.9.jar and bsh.jar). The first of these screws up compilation, because Core should use the more recent fastutil-5.0.10.jar. (This is something IntelliJ seems to do badly: it gives all libraries to all modules by default, rather than just the libraries that correspond to a module in the source tree organization.)
  14. In the same preferences window, under Project Settings, choose Modules, and then choose Core and then choose Dependencies. Change the Module JDK to 1.5. Then you'll still be able to run your Core package code with the standard Applie Java 5 runtime at the command-line.
  15. In the same preferences window, under Project Settings, choose Modules, and then right click RTETest and delete it. Choose Rte, and navigate to the src directory inside test and click Test Sources to label it as a Test Source directory. Similarly delete Test and then choose Core and navigate to the src directory inside test and click Test Sources to label it as a Test Source directory.
  16. In the same preferences window, under Platform Settings, select JDKs, and then look at the Classpath. Click "Add..." and navigate to the jre/lib subdirectory of your soylatte installation and multiselect all 6 jar files there and say OK.
  17. Click on Compiler. Change the amount of memory (at the bottom) to 256 MB. Say OK. Twice.
  18. Close preferences, and say Yes when it asks if you want to reload your project with the new language level.
  19. Choose Build | Make Project. Wait again. But it should work without errors (only warnings). Yippee!!.

Download and Install IntelliJ

You can download IntelliJ for the operating system of your choice at http://www.jetbrains.com/idea/download/index.html. Talk to Chris about obtaining a license. If you don't have a Java JDK, you need to download and install one from http://java.sun.com/j2se/1.5.0/download.jsp before starting to work with IntelliJ.

Create a Project

So really the only things you need to change are Name: and the path to your JDK. The rest of the defaults are fine. Now you've got an empty project. The next step is to download javaNLP.

CVS Integration

IntelliJ 4.0 and higher comes with CVS built in, so downloading the repository is a snap. In the sections that follow, JAVANLP_HOME refers to the module_content_root or the base directory of your local copy of the repository.

Classpath and Compiler options

Style Conventions

IntelliJ lets you specify all sorts of details about code formatting, including tab-width, spacing, newlines, when to use braces, alignment, and so forth. You can easily reformat an entire file to match your code style. We're not sticklers about whether you put a space after a comma in a list (although IntelliJ does let you specify this), but in order to make sure the code stays readable using the editor of your choice we strongly prefer that you use the same indentation standards as everyone else. These are: You can specify this yourself in Settings->Global Code Style or you can import the "official" javaNLP settings file. Just download this file (it's a .jar file because IntelliJ is written in java, but don't let that confuse you; just import it as directed here), and then select File->Import Settings and point the browser to the file.

Ant Integration

Although it's easy to compile your files with IntelliJ itself, IntelliJ also supports Apache Ant compilation for those who prefer it.

Miscellaneous Issues

File Encoding

In order to make sure your file encoding is UNIX-friendly (so you don't get all those ^M's at the end of each line from Window's carriage returns), under Settings->IDE Settings->General, set the "Default Encoding" to UTF-8.

Excluding Directories from Compilation

If someone checked in some bad code that's breaking your compile, or you just want to speed up the compile time for the stuff you're working on, you can exclude files and directories from the IntelliJ compiler in the File->Settings->Compiler dialog.

JavaDoc Headers

When you create new files automatically with IntelliJ, it will make a JavaDoc file header for you. Unfortunately, this header won't even be proper JavaDoc format. Please go to Settings->File Templates and change it. (Hint: add an @author tag!) If you import our style settings file, this will be done for you.

Caret Placement

One IntelliJ default that I (personally) find annoying, is that if you click way off the end of the line, it allows the caret to go there, filling in the intervening space with space characters. You can turn this off in Settings->Editor->Virtual Space by unchecking the "Allow placement of caret after end of line" option.

Explore!

IntelliJ is a fully customizable, extremely flexible and powerful IDE. It has very useful capabilities for code navigation (e.g. type CTRL-b on any class or variable name to go to its definition), and refactoring (e.g. type CTRL-ALT-n to inline a variable or function, or SHIFT-F6 to rename a variable or class). You can change the key mapping to emulate emacs or Mac OSX. You can use and define your own quite sophisticated code-sensitive macros (try declaring a Collection and then type "itco" *TAB*). Time spent exploring and get used to using IntelliJ's advanced capabilities will be repaid ten-fold in terms of saved time coding in the future. (Not to mention reduced headaches!)

Send e-mail to Galen Andrew (galen@cs.stanford.edu) if this is confusing or you need help.

[ JavaNLP Project Home Page ]