Scala At Home

From mi-linux
Revision as of 20:56, 6 February 2011 by In0316 (talk | contribs) (Added section in install-scala.sh script to make Sun version of Java default)
Jump to navigationJump to search

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

This is what you should do:

  • Copy the BASH script below into a file called `install-scala.sh`
  • Open a command line. `cd` to wherever you stored `install-scala.sh`
  • 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 install-scala.sh
  
  • Run the script like this (you will be asked to enter your password):
 
  $ ./install-scala.sh
  
  • Check that Scala was installed properly, like this:
 
  $ source ~/.bashrc
  $ scala
  Welcome to Scala version 2.8.1.final (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
  


install-scala.sh script

 
  #!/bin/bash

  #
  # This script install Scala v1.8.1 and NetBeans on Ubuntu.
  # (c) Sarah Mount 2011
  # 
  
  echo
  echo Getting ready...
  echo
  
  gksudo 'apt-get -y --quiet remove netbeans scala'

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

  gksudo 'apt-get -y --quiet install eclipse sun-java6-jdk'
  gksudo 'update-java-alternatives -s java-6-sun'

  echo
  echo Downloading Scala...
  echo
  
  cd /tmp
  wget http://www.scala-lang.org/downloads/distrib/files/scala-2.8.1.final.tgz
  tar xvzf scala-2.8.1.final.tgz
  
  echo
  echo Installing Scala...
  echo
  
  gksudo 'mv scala-2.8.1.final /opt'
  gksudo 'ln -s /opt/scala-2.8.1.final/ /opt/scala'
  
  echo
  echo Setting environment variables...
  echo
  
  echo "export SCALA_HOME=/opt/scala-2.8.1.final" >> ~/.bashrc
  echo "export PATH=$PATH:/opt/scala-2.8.1.final/bin" >> ~/.bashrc
  
  echo
  echo "Installing NetBeans..."
  echo
  
  gksudo 'apt-get -y --quiet install netbeans'