How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How to Install Scala on CentOS 7

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
18
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Prerequisites:
  2. Step 1: Update your system
  3. Step 2: Install OpenJDK Environment
  4. Step 3: Download and install Scala
  5. Step 4: Examples of using Scala
  6. Want to contribute?


Scala is an object-oriented and functional programming language. It a popular language that has been used for developing applications, such as Spark, Akka, and Lift.

In this article, I will show you how to install Scala on a CentOS 7 server instance.

Prerequisites:

All of the instructions in this article are applicable to a non-root sudo user using CentOS 7. Thus, you need to deploy a fresh Vultr CentOS 7 server instance and create a non-root sudo user before diving in.

Step 1: Update your system

After logging in as the non-root sudo user from your SSH terminal, the first thing you need to do is to update the system:

sudo yum update -y && sudo reboot

Use the same user to log in again after the system reboots.

Step 2: Install OpenJDK Environment

Scala requires the Java runtime version 1.6 or later. Here, you can install the latest version of OpenJDK Runtime Environment 1.8.0 using YUM:

sudo yum install java-1.8.0-openjdk.x86_64

You can validate the installation of Java runtime by running the following command:

java -version

This command should output something that resembles:

openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

Besides, you need to set the “JAVA_HOME” and “JRE_HOME” environment variables.

sudo cp /etc/profile /etc/profile_backup      #Backup the profile file in order to prevent unintentional mistakes
echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
source /etc/profile

Now, you can print the two environment variables for review:

echo $JAVA_HOME
echo $JRE_HOME

Step 3: Download and install Scala

Download and install the latest Scala RPM file from the Scala official website, which at the time of writing is 2.11.8:

cd ~
wget http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.rpm
sudo yum install scala-2.11.8.rpm

Verify your installation:

scala -version

The output should resemble:

Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL

Step 4: Examples of using Scala

The Scala installation is complete. Let’s have a look at how to use it.

Run the Scala code runner and get into the Scala shell:

scala

In the Scala shell, you can calculate the result of a formula:

scala> 1+2
res0: Int = 3

or, execute a function:

scala> println("Hello Scala")
Hello Scala

If you want to quit the Scala shell:

:q

You can also use the scalac program to compile .scala source code.

Write the source code of an example program using vi:

vi hello.scala

Input the code segment below:

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello World!")
  }
}

Save and quit:

:wq

Compile the source code with scalac:

scalac hello.scala

The program will output two compiled files: HelloWorld.class and HelloWorld$.class. You can run the compiled file with scala:

scala HelloWorld

The output will read:

Hello World!

Moreover, you can embed Scala functions into a bash script, and then run the script using bash:

vi script.sh

Populate the file with:

#!/bin/sh
exec scala "$0" "[email protected]"
!#
object HelloWorld extends App {
  println("Hello world!")
}

HelloWorld.main(args)

Save and quit:

:wq

Run the script in the bash shell:

sh script.sh

Again, the output will read:

Hello world!

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

How To Install Vesta CP on CentOS 6

Monitor Your Devices Using LibreNMS on CentOS 7

Install Nginx with Ngx_pagespeed on CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Create and Use Alias Command in Linux

4 years ago

How to Setup a WebDAV Server Using Apache on CentOS 7

3 years ago

Installing MongoDB on FreeBSD 10

4 years ago
How To Prepare For Migration To Windows Server 2019

How To Prepare For Migration To Windows Server 2019

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.