Difference between revisions of "Scala At Home"

From mi-linux
Jump to navigationJump to search
(New page: 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 ...)
 
(Removed the gksudo and replaced with sudo; added instructions to use a text terminal.)
 
(13 intermediate revisions by the same user not shown)
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.
 +
 
 +
It would be a <strong>very good idea</strong> 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:
 
This is what you should do:
  
* Copy the BASH script below into a file called `install-scala.sh`
+
* Copy the BASH script below into a file called <code>install-scala.sh</code>
* Open a command line. `cd` to wherever you stored `install-scala.sh`
+
* Open a command line. <code>cd</code> to wherever you stored <code>install-scala.sh</code>
* Make the script executable by executing the following command on the shell (remember you don't type in the $, that's the shell prompt!):
+
* Make the script executable by executing the following command on the shell (remember you don't type in the <code>$</code>, that's the shell prompt!):
 
   <nowiki>
 
   <nowiki>
  $ chmod +x install-scala.sh
+
$ chmod +x install-scala.sh
 
   </nowiki>
 
   </nowiki>
 +
 +
* <strong>IMPORTANT</strong> Now move to a text terminal. Press <code>Ctrl+Alt+F4</code> and log in. (If at any point you need to move back to your normal desktop press <code>Ctrl+Alt+F7</code>).
 +
* <code>cd</code> to wherever you stored <code>install-scala.sh</code>
 
* Run the script like this (you will be asked to enter your password):
 
* Run the script like this (you will be asked to enter your password):
 
   <nowiki>
 
   <nowiki>
  $ ./install-scala.sh
+
$ ./install-scala.sh
 
   </nowiki>
 
   </nowiki>
 
* Check that Scala was installed properly, like this:
 
* Check that Scala was installed properly, like this:
 
   <nowiki>
 
   <nowiki>
  $ 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.
 
    
 
    
  scala>  
+
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
+
* Move back to your normal desktop by pressing <code>Ctrl+Alt+F7</code>.
* '''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.
 
  
  
Line 32: Line 36:
  
 
   <nowiki>
 
   <nowiki>
  #!/bin/bash
+
#!/bin/bash
  
  #
+
#
  # 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
  #  
+
#  
 
    
 
    
  echo
+
echo
  echo Getting ready...
+
echo Getting ready...
  echo
+
echo
 
    
 
    
  gksudo 'apt-get -y --quiet remove netbeans scala'
+
sudo 'apt-get -y --quiet remove scala'
 
+
 
  echo
+
echo
  echo Downloading Scala...
+
echo Installing the Sun version of Java and making it default...
  echo
+
echo
 
+
 
  cd /tmp
+
# Maverick partner, since oneiric doesn't have Oracle / Sun Java yet.
  wget http://www.scala-lang.org/downloads/distrib/files/scala-2.8.1.final.tgz
+
sudo "apt-add-repository 'deb http://archive.canonical.com/ubuntu maverick partner'"
  tar xvzf scala-2.8.1.final.tgz
+
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
 +
echo Downloading Scala...
 +
echo
 
    
 
    
  echo
+
cd /tmp
  echo Installing Scala...
+
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.9.1.final.tgz
  echo
+
tar xvzf scala-2.9.1.final.tgz
 
    
 
    
  gksudo 'mv scala-2.8.1.final /opt'
+
echo
  gksudo 'ln -s /opt/scala-2.8.1.final/ /opt/scala'
+
echo Installing Scala...
 +
echo
 
    
 
    
  echo
+
sudo 'mv scala-2.9.1.final /opt'
  echo Setting environment variables...
+
sudo 'ln -s /opt/scala-2.9.1.final/ /opt/scala'
  echo
 
 
    
 
    
  echo "export SCALA_HOME=/opt/scala-2.8.1.final" >> ~/.bashrc
+
echo
  echo "export PATH=$PATH:/opt/scala-2.8.1.final/bin" >> ~/.bashrc
+
echo Setting environment variables...
 +
echo
 
    
 
    
  echo
+
echo "export SCALA_HOME=/opt/scala-2.9.1.final" >> ~/.bashrc
  echo "Installing NetBeans..."
+
echo "export PATH=$PATH:/opt/scala-2.9.1.final/bin" >> ~/.bashrc
  echo
 
 
    
 
    
  gksudo 'apt-get -y --quiet install netbeans'
+
source ~/.bashrc
 
   </nowiki>
 
   </nowiki>

Latest revision as of 11:45, 27 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.

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 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
  
  • 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 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.
  • Move back to your normal desktop by pressing Ctrl+Alt+F7.


install-scala.sh script

 
#!/bin/bash

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

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

# Maverick partner, since oneiric doesn't have Oracle / Sun Java yet.
sudo "apt-add-repository 'deb http://archive.canonical.com/ubuntu 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
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
  
sudo 'mv scala-2.9.1.final /opt'
sudo '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