Programming  /  Scala August 17, 2010

Learning Scala part two – Installation and tools

At the time of this writing the latest version of Scala is 2.8. We can download the latest release from http://www.scala-lang.org/downloads where we’ll find download packages for different operating systems. The easiest way of installing Scala is to grap the first option, the IzPack installer which works on all platforms (assuming that you have Java installed).

Once you’ve downloaded the IzPack installer you navigate to the folder you downloaded it to in a console and type java –jar scala-2.8.0.final-installer.jar. In my case, running Windows it looked like this:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Joel>cd Downloads

C:\Users\Joel\Downloads>java -jar scala-2.8.0.final-installer.jar

 

IzPack-Scala-installer

environment-variablesOnce the installer is done you’ll have a new folder named scala in your programs folder. The installer will also add environment variables so that you should be able to just write scala or scalac in the console to start Scala in interactive mode or use the compiler (more on this in the next part).

However, for me this didn’t work. When I wrote scala in my console on my Windows 7 machine it simply said “\scala was unexpected at this time”.

C:\Users\Joel>scala
\scala was unexpected at this time.
C:\Users\Joel>

It turned out that the problem was that the installer had set the SCALA_HOME environment variable to C:\Program Files(x86)\scala which due to the space between Program and Files didn’t work. After all it's only 2010 and I guess we need to wait a couple of decades more until Windows will handle spaces in paths in a perfect way. Anyway, changing the SCALA_HOME environment variable to “c:\progra~2\scala” fixed this issue and Scala was installed.

Development tools

With Scala installed I went hunting for nice tools to use when writing my code. Being a total Visual Studio (and ReSharper) junkie, and considering that this adventure is about going outside my comfort zone I decided to not get an IDE right away but just a nice text editor with some syntax highlighting.

Notepad++ with syntax highlighting for Scala

After some looking around I settled on using Notepad++. Adding syntax highlighting support for Scala was really easy (thanks to this post). I just copied {scala_root}\misc\scala-tool-support\notepad-plus\userDefineLang.xml to {myUserFolder}\AppData\Roaming\Notepad++ and restarted Notepad++.

By the way, did I mention that I’m an IDE junkie? So, I just couldn’t stop myself from looking for an IDE as well and it turned out that there are a few with support for Scala. As a side note it’s also worth mentioning that if you install one of these and grab the Scala support you don’t need to install Scala yourself. Anyhow, I ended up getting both Eclipse and IntelliJ IDEA.

Installing Scala support for Eclipse

Installing Scala support for Eclipse was extremely easy once I actually bothered to read the bold text that said that it wasn’t available for version 3.6 of Eclipse yet. Using Eclipse 3.5 I selected Help->Install New Software which opened up the dialog shown in the image below. In it I just pasted http://download.scala-ide.org/update-current, hit the next button and a few minutes later the Scala support was installed.

eclipse-installation-dialog

Installing Scala support for IntelliJ IDEA

Installing the Scala plug-in for IntelliJ IDEA was even simpler than for Eclipse. I just clicked on the Open Plugin Manager button on the welcome screen, did a search for Scala. A couple of plug-ins turned up. Installation involved right clicking on the plug-in in the search result, selecting Download and Install and finally restarting IntelliJ.

intellij-plugin-manager

Recap and a look at what’s next

With Scala installed and some nice tools to play with we’ll actually write some code in the next part as we’ll look at different ways to execute Scala code and do the mandatory Hello world application.

About this post and the Learning Scala series

This post is a part of a series of posts in which I describe my experiences while trying to learn Scala. I try to do it in the form of a tutorial as I find doing so is an excellent way of consolidating knowledge and hopefully I can also help others. However, keep in mind that I’m in no way an expert on Scala. This is just a way to document what I’ve learned so far and there might be some things that I’ve misunderstood. If you’ve found such a thing and would like to help me correct that misunderstanding, or if you would like to leave any other kind of feedback don’t hesitate to leave a comment!

You can find links to all posts in this series at the bottom of the first post.

PS. For updates about new posts, sites I find useful and the occasional rant you can follow me on Twitter. You are also most welcome to subscribe to the RSS-feed.

Joel Abrahamsson

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more

Comments

comments powered by Disqus

More about Scala