Install Scala 2.11.7 and sbt 0.13.9 on Ubuntu 14.04

Posted on Monday, February 1, 2016



Just a quick guide to install Java 1., Scala 2.11.7 and sbt 0.13.9 on Ubuntu 14.04.







Java 1.8


I want to use Oracle Java 1.8.  To install this on Ubuntu 14.04 takes a few extra steps, like setting it up to auto accept the license.  At any rate here is the procedure.



  > echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
  > echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
 > echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
 > sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
 > sudo apt-get update
 > sudo apt-get -y install oracle-java8-installer




Check it


  > java -version











Scala 2.11.7





Copy the Hyperlink to scala-2.11.7.tgz



  > wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz




Untar/gunzip it


  > tar -xvf scala-2.11.7.tgz


Move scala to /usr/lib/scala


  > sudo mkdir /usr/lib/scala
  > sudo mv scala-2.11.7 /usr/lib/scala/


Set up scala


  > sudo touch /usr/bin/scala
  > sudo ln -fs /usr/lib/scala/scala-2.11.7/bin/scala /usr/bin/scala


Set up scalac


  > sudo touch /usr/bin/scalac
  > sudo ln -fs /usr/lib/scala/scala-2.11.7/bin/scalac /usr/bin/scalac




Test it


  > scala -version
  > scalac -version









sbt 0.13.9








Copy the Link Address.

Download sbt 0.13.9


  > wget https://dl.bintray.com/sbt/native-packages/sbt/0.13.9/sbt-0.13.9.tgz




Untar/gunzip it


  > tar -xvf sbt-0.13.9.tgz


Move scala to /usr/lib/sbt


  > sudo mkdir /usr/lib/sbt
  > sudo mv sbt /usr/lib/sbt/sbt-0.13.9


Set up sbt


  > sudo touch /usr/bin/sbt
  > sudo ln -fs /usr/lib/sbt/sbt-0.13.9/bin/sbt /usr/bin/sbt





Test it


  > sbt -version










It starts to download the jar files it needs.






Clean up




  > rm sbt-0.13.9.tgz
  > rm scala-2.11.7.tgz







All in one script


Create this script


  > vi install_java_scala_sbt.sh




#!/bin/bash
#
# Script to Install
#     Oracle Java 1.8
#     Scala 2.11.7
#     sbt 0.13.9
#
##############################

#Script must be run as root/sudo
if [[ $EUID -ne 0 ]]; then
    echo "This script must be run with admin privileges 'sudo'"
    echo "exiting...."
    exit 1
fi

#Install Oracle Java 1.8
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get -y install oracle-java8-installer



#Install Scala 2.11.7
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar -xvf scala-2.11.7.tgz
mkdir /usr/lib/scala
mv scala-2.11.7 /usr/lib/scala/
touch /usr/bin/scala
ln -fs /usr/lib/scala/scala-2.11.7/bin/scala /usr/bin/scala
touch /usr/bin/scalac
ln -fs /usr/lib/scala/scala-2.11.7/bin/scalac /usr/bin/scalac


#Install sbt 0.13.9
wget https://dl.bintray.com/sbt/native-packages/sbt/0.13.9/sbt-0.13.9.tgz
tar -xvf sbt-0.13.9.tgz
mkdir /usr/lib/sbt
mv sbt /usr/lib/sbt/sbt-0.13.9
touch /usr/bin/sbt
ln -fs /usr/lib/sbt/sbt-0.13.9/bin/sbt /usr/bin/sbt
#Need to run this to download needed jar files
sbt -version

#Clean up
rm sbt-0.13.9.tgz
rm scala-2.11.7.tgz

java -version
scala -version
sbt -version





Chmod and run it


  > chmod u+x install_java_scala_sbt.sh
  > sudo ./install_java_scala_sbt.sh



I also made this script into a gist on github at




References



No comments:

Post a Comment