Scala At Home

From mi-linux
Jump to navigationJump to search

The steps needed to install Scala on Ubuntu are slightly complicated, as you need the latest version of Scala (not the one that comes with Ubuntu). If you have already installed Scala, the instructions below will remove them and install the correct versions for you.

It would be a very good idea to print these instructions out or have them open on your phone before you start, as you won't always be able to see them on the screen...

This is what you should do:

  • Copy the BASH script below into a file called
  • Open a command line. cd to wherever you stored
  • Make the script executable by executing the following command on the shell (remember you don't type in the $, that's the shell prompt!):
$ chmod +x
  • IMPORTANT Now move to a text terminal. Press Ctrl+Alt+F4 and log in. (If at any point you need to move back to your normal desktop press Ctrl+Alt+F7).
  • cd to wherever you stored
  • Run the script like this (you will be asked to enter your password):
$ ./
  • Check that Scala was installed properly, like this:
$ source ~/.bashrc
$ scala
Welcome to Scala version (Java HotSpot(TM) Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.
scala> // Press Ctrl+d to get out of this interpreter
  • You should now have Scala version 2.9.1 correctly installed.
  • Move back to your normal desktop by pressing Ctrl+Alt+F7. script


# This script install Scala v1.9.1 on Ubuntu.
# (c) Sarah Mount 2012
echo Getting ready...
sudo 'apt-get -y --quiet remove scala'

echo Installing the Sun version of Java and making it default...

# Maverick partner, since oneiric doesn't have Oracle / Sun Java yet.
sudo "apt-add-repository 'deb maverick partner'"
sudo 'apt-get update'
sudo 'apt-get install eclipse sun-java6-jdk'
sudo 'update-java-alternatives -s java-6-sun'
sudo 'update-javac-alternatives -s javac-6-sun'
sudo 'update-javap-alternatives -s javap-6-sun'

echo Downloading Scala...
cd /tmp
tar xvzf
echo Installing Scala...
sudo 'mv /opt'
sudo 'ln -s /opt/ /opt/scala'
echo Setting environment variables...
echo "export SCALA_HOME=/opt/" >> ~/.bashrc
echo "export PATH=$PATH:/opt/" >> ~/.bashrc
source ~/.bashrc