IntelliJ Idea 10 and Scala – Tutorial on running Scala in IntelliJ

Learning new programming languages is what we all do to know which one will work best for the project that we’re working on. That’s why I decided to try out Scala. Scala is quite young programming language based on java. Unfortunatelly it suffers from many problems that usually touch new things, which are: unsufficient number of examples, handful of IDE with support for it, and basically that’s much enough to make you return to your well-known and favourite language.

Same things happened with my attempts to Scala. At first I have thought about using Eclipse. It is even possible to download plugin to scala for Eclipse. But let’s face facts: Eclipse takes enormous ammount of memory when it comes tu using Scala, there is no ‘intellisense’ (syntax support), and it returns information about syntax error, while the code is fine, and there is no compilation errors. All that had made me look for some other solution.

IntelliJ Idea turned out to be what I was looking for. It comes in 2 versions, ultimate and community. You can use community edition for free, whereas Ultimate costs 350 Euros (85 Euros for the students), but you can try it out for 30 days during the trial.  But I’m not here to sell it to you, so why don’t we move on to the tutorial.

Scala doesn’t come as a default from the package. You have to prepare the IDE to work with it.

  1. Download Java Development Kit from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Download Scala compiler, sources, code examples and API from here: http://www.scala-lang.org/downloads . Unpack it to any folder you wish.
  3. Download IntelliJIDEA from here http://www.jetbrains.com/idea/download/
  4. Install Intellij Idea and run it. On the welcome screen press ‘open plugin manager’
  5. The following window will open
  6. Choose “Available” tab, search for Scala plugin, right click on it and choose “Download and install it”.
  7. Restart IntelliJ
  8. Click File -> New Project, you should see the below screen:
  9. In the project Name write whatever you want, specify the project files location. Press Next, and if it is the first time you run IntelliJ you will be asked to configure Java JDK folder.
  10. Next point the wizard to the folder where you have unpacked your scala compiler. It’s good to put devel-docs inside the compiler folder, so that you will be able to have scala syntax support 
  11. Now we will create the first program. Right click on the src package and then choose to create New Package
  12. Right click the newly created package and choose New -> Scala File, pick the name, and from the dropdown menu choose “object”
  13. Great, now put some scala code in it, and run it in the following way. Near to the green Run button, there is an arrow that show the menu of “run configuration”. Click Edit Configuration 
  14. From the menu that shows up choose “(+)”
  15. Press “(…)” button which can be found under the “Main class:” label. Then from the menu that shows up choose the source file that you want to run. Press OK. Then choose the name for the app in the menu shown below. Press OK, and then press the green arrow to run the code. Enjoy 

One Comment to “IntelliJ Idea 10 and Scala – Tutorial on running Scala in IntelliJ”

  1. [...] particularly like IntelliJ in the Java space) I suspect IntelliJ is positioned quite well with the Scala uptick in [...]

    Like or Dislike: Thumb up 0 Thumb down 0


Leave a Reply