openSUSE

How To Install Scala on openSUSE

Install Scala on openSUSE

In this tutorial, we will show you how to install Scala on openSUSE. Scala, a powerful and versatile programming language, combines object-oriented and functional programming paradigms, making it an excellent choice for developing scalable and efficient applications. openSUSE, a popular Linux distribution known for its stability and flexibility, provides an ideal platform for running Scala.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Scala programming language on openSUSE.

Prerequisites

  • A server running one of the following operating systems: openSUSE (Leap or Tumbleweed)
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. openSUSE provides the Terminal application for this purpose. It can be found in your Applications menu.
  • You’ll need an active internet connection to download Scala and its dependencies.
  • You’ll need administrative (root) access or a user account with sudo privileges.

Install Scala on openSUSE

Step 1. Keeping your system up-to-date is a best practice for security and performance. Open your terminal and execute the following command to refresh your system’s package repository and upgrade all your installed packages to their latest versions:

sudo zypper refresh
sudo zypper update

Step 2. Installing Java.

Before diving into the installation process, it’s crucial to ensure that your openSUSE system meets the necessary prerequisites. Scala requires Java to run, so you’ll need to verify that Java is installed on your machine. Open a terminal and run the following command:

java -version

If Java is installed, you should see the version information displayed. If not, you can install Java using the zypper package manager:

sudo zypper install java-1_8_0-openjdk

Step 2. Installing Scala Programming Language on openSUSE.

To begin the installation process, visit the official Scala download page. Select the “Linux” tab and copy the download link for the latest stable version of Scala. At the time of writing, the latest version is 2.13.6.

Open a terminal and navigate to the directory where you want to download the Scala binaries. Use the wget command to download the Scala archive:

wget https://downloads.lightbend.com/scala/2.13.6/scala-2.13.6.tgz

Once the download is complete, verify the integrity of the downloaded archive by running the sha256sum command and comparing the output with the provided checksum on the Scala download page:

sha256sum scala-2.13.6.tgz

Create a directory where you want to install Scala. For example, let’s create a directory called “scala” in the /opt directory:

sudo mkdir /opt/scala

Extract the downloaded Scala archive using the tar command with the following options:

x: Extract the files from the archive
v: Verbosely list the files being extracted
f: Specify the archive file name
C: Change to the specified directory before extracting

sudo tar xvf scala-2.13.6.tgz -C /opt/scala

After the extraction process completes, verify that the Scala files are present in the installation directory:

ls /opt/scala

You should see a directory named scala-2.13.6 containing the Scala files.

Step 3. Set PATH Variable.

To run Scala from anywhere in the terminal, you need to add Scala’s bin directory to your system’s PATH variable. The PATH variable specifies the directories where executable programs are located.

First, check the current value of the PATH variable:

echo $PATH

To add Scala’s bin directory to the PATH, open your shell’s configuration file. The configuration file depends on the shell you are using. For Bash, it is usually .bashrc or .bash_profile located in your home directory. For Zsh, it is .zshrc.

Open the configuration file using a text editor. For example, if you are using Bash, run:

nano ~/.bashrc

Add the following line at the end of the file, replacing /opt/scala/scala-2.13.6 with the actual path to your Scala installation directory:

export PATH=$PATH:/opt/scala/scala-2.13.6/bin

To apply the changes, reload the shell configuration file:

source ~/.bashrc

To verify that Scala is installed correctly, open a new terminal and run the following command:

scala -version

If the installation was successful, you should see the Scala version information displayed.

You can also start the Scala REPL (Read-Eval-Print Loop) by running the Scala command without any arguments:

scala

The Scala REPL allows you to interactively execute Scala code. Try running a simple expression:

println("Hello, Scala!")

To exit the REPL, type :quit and press Enter.

Congratulations! You have successfully installed Scala. Thanks for using this tutorial for installing the Scala programming language on your openSUSE system. For additional or useful information, we recommend you check the official Scala website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button