Difference between revisions of "Scala At Home"

From mi-linux
Jump to navigationJump to search
m
(Removed netbeans; updated Scala version)
Line 1: Line 1:
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.
+
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.
  
 
This is what you should do:
 
This is what you should do:
Line 17: Line 17:
 
$ source ~/.bashrc
 
$ source ~/.bashrc
 
$ scala
 
$ scala
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Server VM, Java 1.6.0_22).
+
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Server VM, Java 1.6.0_22).
 
Type in expressions to have them evaluated.
 
Type in expressions to have them evaluated.
 
Type :help for more information.
 
Type :help for more information.
Line 23: Line 23:
 
scala> // Press Ctrl+d to get out of this interpreter
 
scala> // Press Ctrl+d to get out of this interpreter
 
   </nowiki>
 
   </nowiki>
* You should now have Netbeans and Scala version 2.8.1 correctly installed.
+
* You should now have Scala version 2.9.1 correctly installed.  
* Open Netbeans, note which version of Netbeans you have (it will probably be 6.9)
 
* '''If you have Netbeans 2.9''' close Netbeans, and follow the instructions here: http://wiki.netbeans.org/Scala69#Install_with_NetBeans_6.9 to install the Scala plugin
 
* '''If you have some other version of Netbeans''' look here: http://wiki.netbeans.org/Scala#Get_Started to find the instructions for the version you do have.
 
* Edit the file <code>/etc/netbeans.conf</code>. You need to have superuser privileges to do this, so use the command:
 
  <nowiki>
 
$ sudo gedit /etc/netbeans.conf
 
  </nowiki>
 
* Find the line that looks like this:
 
  <nowiki>
 
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.pmoffscreen=false"
 
  </nowiki>
 
And add this to the end of the line, before the closing <code>"</code>:
 
  <nowiki>
 
J-Dscala.home=/opt/scala-2.8.1.final/
 
  </nowiki>
 
* Note, that you MAY get a warning message about this directory when you start Netbeans, just ignore it.
 
  
  
Line 48: Line 32:
  
 
#
 
#
# This script install Scala v1.8.1 and NetBeans on Ubuntu.
+
# This script install Scala v1.9.1 on Ubuntu.
# (c) Sarah Mount 2011
+
# (c) Sarah Mount 2012
 
#  
 
#  
 
    
 
    
Line 56: Line 40:
 
echo
 
echo
 
    
 
    
gksudo 'apt-get -y --quiet remove netbeans scala'
+
gksudo 'apt-get -y --quiet remove scala'
  
 
echo
 
echo
Line 70: Line 54:
 
    
 
    
 
cd /tmp
 
cd /tmp
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.8.1.final.tgz
+
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.9.1.final.tgz
tar xvzf scala-2.8.1.final.tgz
+
tar xvzf scala-2.9.1.final.tgz
 
    
 
    
 
echo
 
echo
Line 77: Line 61:
 
echo
 
echo
 
    
 
    
gksudo 'mv scala-2.8.1.final /opt'
+
gksudo 'mv scala-2.9.1.final /opt'
gksudo 'ln -s /opt/scala-2.8.1.final/ /opt/scala'
+
gksudo 'ln -s /opt/scala-2.9.1.final/ /opt/scala'
 
    
 
    
 
echo
 
echo
Line 84: Line 68:
 
echo
 
echo
 
    
 
    
echo "export SCALA_HOME=/opt/scala-2.8.1.final" >> ~/.bashrc
+
echo "export SCALA_HOME=/opt/scala-2.9.1.final" >> ~/.bashrc
echo "export PATH=$PATH:/opt/scala-2.8.1.final/bin" >> ~/.bashrc
+
echo "export PATH=$PATH:/opt/scala-2.9.1.final/bin" >> ~/.bashrc
 
    
 
    
echo
 
echo "Installing NetBeans..."
 
echo
 
 
 
gksudo 'apt-get -y --quiet install netbeans'
 
 
 
source ~/.bashrc
 
source ~/.bashrc
 
   </nowiki>
 
   </nowiki>

Revision as of 16:39, 9 February 2012

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.

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.9.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
  
  • You should now have Scala version 2.9.1 correctly installed.


install-scala.sh script

 
#!/bin/bash

#
# This script install Scala v1.9.1 on Ubuntu.
# (c) Sarah Mount 2012
# 
  
echo
echo Getting ready...
echo
  
gksudo 'apt-get -y --quiet remove 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.9.1.final.tgz
tar xvzf scala-2.9.1.final.tgz
  
echo
echo Installing Scala...
echo
  
gksudo 'mv scala-2.9.1.final /opt'
gksudo 'ln -s /opt/scala-2.9.1.final/ /opt/scala'
  
echo
echo Setting environment variables...
echo
  
echo "export SCALA_HOME=/opt/scala-2.9.1.final" >> ~/.bashrc
echo "export PATH=$PATH:/opt/scala-2.9.1.final/bin" >> ~/.bashrc
  
source ~/.bashrc