Problem scenario
You want to install Scala to an Ubuntu instance of AWS. How do you do this?
Solution
Prerequisite
Verify you have 1 GB of RAM. Run this command: sudo dmidecode -t 17 | grep Size
If you see 512 MB in the output, then you will not be able to get Scala installed. You will need an AWS instance with a flavor that has 1 GB of RAM or more. To upgrade the flavor to have more memory, see this posting. To add virtual memory (aka swap space), see this posting.
Method
1. Run these eight commands (including the long one in the middle that is not in bold):
sudo apt-get update
sudo apt-get -y install openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get -y install sbt
sudo apt -y install scala
2. Test if it worked (optional step):
sbt new scala/hello-world.g8
3. You may want to reboot or export a classpath variable. This is an optional step. Once you do this, you can run this command: scala version