Finally, you found the place that shows you how to install Scala on Linux from
binaries. Even the Scala's official website promotes installing on IntelliJ or
installing using SBT. However, I prefer to install Scala the old school way
using binaries for testing purposes because it gives me more control on what
kind of changes are made on my system. For any hardcore development purposes,
I do use
Scala on IntelliJ Idea. This article explains how to install Scala using pre-built binaries.
Step 01:
Download the Scala binaries from the official website. This article uses
scala-2.13.4.tgz as the example.
Step 02:
Open a terminal and change the directory to the
/usr/local
cd /usr/local
Step 03:
Extract the downloaded tgz file
sudo tar -xvzf ~/Downloads/scala-2.13.4.tgz
Step 04 (Optional):
Rename the folder to scala.
sudo mv scala-2.13.4 scala
Step 05:
Enter the following command to open the environment variables file. Vim is
used in the following command. Use your favorite editor to open the file.
sudo vi /etc/environment
Step 06:
In the opened file, add the following bin folder to the existing PATH
variable.
/usr/local/scala/bin
Add the following environment variables at the end of the file:
SCALA_HOME="/usr/local/scala"
After these changes, the
/etc/environment file should look
like this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk-14.0.1/bin:/usr/local/scala/bin>
JAVA_HOME="/usr/lib/jvm/jdk-14.0.1"
SCALA_HOME="/usr/local/scala"
Save the changes and close the editor.
Step 07:
Log out the system and login again to apply the changes. If you cannot
logout/restart the system, you may need to enter the following command in
every new Terminal sessions to load the changes made to the environment file.
source /etc/environment
Open a terminal and enter the following command to check the Scala version:
scala --version
If you get the installed Scala version as the output, you have successfully
installed Scala on your system. Feel free to comment below if you have any
questions or suggestions.
EmoticonEmoticon