Get my first Scala code running with IntelliJ 11 Community Edition

I've enrolled on Functional Programming Principles in Scala class at Coursera and it seems the official IDE for the class is Eclipse. However, I started to hate it only after a few hours of using it because it kept freezing and I had to force quit it over and over.

Since I am a fan of Jetbrains IDEs (I use both RubyMine and PhpStorm) I wanted to give IntelliJ a shot. Fortunately, IntelliJ Community Edition, which is free, supports Scala through a plugin, but it was a little tricky for a beginner to see my first Scala "Hello, World!" running. Thanks for the FP class forum members, I could finally figured out how to do. Here I would like to share.

Install Scala and SBT

$ brew install scala
$ brew install sbt

Setting up IntelliJ for a Scala sbt project

The instruction below is copied from a FP class forum thread and is extremely useful.

  1. Download IntelliJ 11.1.3 from http://www.jetbrains.com/idea/
  2. Install the latest scala plugin from the plugins manager dialog. Also make sure to go into Project Structure and select your JDK.
  3. Add the following lines to /project/plugins.sbt
    addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0")
  4. Build the project files for Idea:
    $ cd <PROJECT_DIR>
    $ sbt gen-idea
  5. open up IntelliJ and do Open Project and open the top level directory
  6. Click the yellow [ T ] box in the lower right corner to turn on type-aware highlighting for scala.

 References

  1. Functional Programming Principles in Scala: Setting up IntelliJ from the Guardian's developer blog
  2. https://github.com/mpeltonen/sbt-idea
  3. https://class.coursera.org/progfun-2012-001/forum/thread?thread_id=54 see Dhananjay Ragade's comment.

About Sanghyun Park

a.k.a Baxang. Software engineer lives in Sydney, Australia born in Seoul, South Korea.