Skip to content

Instantly share code, notes, and snippets.

@absognety
Last active April 11, 2023 06:22
Show Gist options
  • Save absognety/db3247222e6e04b6c22acc8e6e248f90 to your computer and use it in GitHub Desktop.
Save absognety/db3247222e6e04b6c22acc8e6e248f90 to your computer and use it in GitHub Desktop.
Setup Scala environment in Linux/RHEL/CentOS/Debian/Ubuntu/Fedora releases
Check for Java Development Kit (JDK) version
$ java -version
java version "1.7.0_171"
OpenJDK Runtime Environment (rhel-2.6.13.0.el7_4-x86_64 u171-b01)
OpenJDK 64-Bit Server VM (build 24.171-b01, mixed mode)

For scala to be set up JDK 8 or greater version is required
if JDK/OpenJDK version is less than 1.8 then follow the below steps

Download java 1.8
$cd /opt
$mkdir java
$cd java 
$wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz
$tar -zxvf jdk-8u201cd jdk1.8.0_201-linux-x64.tar.gz
$pwd
$cd jdk1.8.0_201 #cd jdk1.8.*
$update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_201/bin/java 100
$update-alternatives --config java
$update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_201/bin/javac 100
$update-alternatives --config javac
$update-alternatives --install /usr/bin/jar jar /opt/java/jdk1.8.0_201/bin/jar 100
$update-alternatives --config jar
$export JAVA_HOME=/opt/java/jdk1.8.0_201/
$export JRE_HOME=/opt/java/jdk1.8.0_201/jre
$export PATH=$PATH:/opt/java/jdk1.8.0_201/bin:/opt/java/jdk1.8.0_201/jre/bin
$java -version
Next Step is to setup scala environment
#creating en empty folder linux file system
$mkdir app
$cd app

#scala 2.11.6
$wget www.scala-lang.org/files/archive/scala-2.11.6.tgz 
$tar -xvzf scala-2.11.6.tgz
$cd scala-2.11.6
$cd bin

#Invoking scala commands - check if it is working from command line
./scala 
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_201).
Type in expressions to have them evaluated.
Type :help for more information.

scala>
#Add below path to your ./bashrc or .profile
$export PATH=/app/scala-2.11.6/bin:$PATH

sbt installation and setup - checkout the scaladoc
$cd ../opt
$mkdir sbt

#for RHEL/centOS - Linus distributions
$curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
$sudo yum install sbt

Infographic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment