This article is about installing scala 2.8.1 on ubuntu. Scala is also in the ubuntu repositories but then you get version 2.7.7. If you don’t mind using that version then skip the rest of the article and install using:

$ sudo apt-get install scala

It might be that you already have installed Scala on your ubuntu OS. You can remove it using the following command. (This step is not necessary).

$ sudo apt-get remove scala

Installing java development kit
In some cases Scala seems to have problems with openjdk-6 therefore we have to install the sun version of the JDK:

$ sudo apt-get install sun-java6-jdk

To make this the default java version do:

$ sudo update-java-alternatives -s java-6-sun

Make sure the right version is installed by:

$ java -version

Installing Scala
Download scala 2.8.1 from and choose the unix version.

In this article Scala will be installed in /opt/scala/ But you can of-course choose to install it in another location. But make sure you change the paths shown here accordingly.

Open a terminal and go to the directory where you downloaded the file and do the following:

$ sudo mkdir -p /opt/scala
$ sudo cp /opt/scala
$ cd /opt/scala
$ sudo tar -zxvf

Scala is now installed in /opt/scala/ We need to make to executables available on the path. Therefore we adjust the file ~/.bashrc in your home directory. Open the file with editor of choice and add at the end of the file:

export SCALA_HOME=/opt/scala/

Normally this would be the end of the installation, but I ran into some problems with the FSC (Fast Scala Compiler). If got the following exception while running scala HelloWorld.scala

Could not connect to compilation daemon.
Exception in thread "main" java.lang.Exception: fsc failure

Normally if the FSC deamon is not started yet it should be started automatically but somehow this doesn’t work on my machine. Maybe it is to slow (Intel Atom A330) and gives a timeout before it is actually started? I can fix this by calling FSC manually first:

$ fsc
Could not connect to compilation daemon.
$ ps -ef | grep scala
paulh     4234     1 30 15:24 pts/0    00:00:03 java -Xmx256M -Xms32M -cp /opt/scala/ -Dscala.home=/opt/scala/ -Denv.emacs=

Although it says it could not connect to the compilation daemon, it was started anyway. Now all works like a charm.

I could add fsc to the ubuntu startup script but that isn’t a great solution to the problem, especially because Scala 2.7.7 which Ubuntu provides does not have this problem. If anyone has a better solution then please put it down this article.

Let’s hope that Ubuntu will upgrade scala in version 11.04.