Scala is a modern JVM programming language that supports both object-oriented and functional programming styles.
JDK
You will need to install JDK first on your dev machine if you haven't already done so.
Java version 11 or later is required.
For example, on Ubuntu
sudo apt install default-jdk
$ javac --version
javac 17.0.2
Scala
There are a number of different ways to set up a scala development environment.
You can just install the scala compiler. For example, on ubuntu,
sudo apt install scala
Many professional scala developers use sbt (scala build tool), however, instead of directly using the scala compiler.
sudo apt install sbt
$ sbt --version
copying runtime jar...
sbt version in this project: 1.6.2
sbt script version: 1.6.2
If you install sbt, it comes with other scala tools such as the compiler.
$ sbt --help
Usage: sbt [options]
-h | --help print this message
-v | --verbose this runner is chattier
-V | --version print sbt version information
--numeric-version print the numeric sbt version (sbt sbtVersion)
--script-version print the version of sbt script
shutdownall shutdown all running sbt-launch processes
-d | --debug set sbt log level to debug
-debug-inc | --debug-inc
enable extra debugging for the incremental debugger
--no-colors disable ANSI color codes
--color=auto|always|true|false|never
enable or disable ANSI color codes (sbt 1.3 and above)
--supershell=auto|always|true|false|never
enable or disable supershell (sbt 1.3 and above)
--traces generate Trace Event report on shutdown (sbt 1.3 and above)
--timings display task timings report on shutdown
--sbt-create start sbt even if current directory contains no sbt project
--sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
--sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
--sbt-cache <path> path to global cache directory (default: operating system specific)
--ivy <path> path to local Ivy repository (default: ~/.ivy2)
--mem <integer> set memory options (default: 1024)
--no-share use all local caches; no sharing
--no-global uses global caches, but does not use global ~/.sbt directory.
--jvm-debug <port> Turn on JVM debugging, open at the given port.
--batch disable interactive mode
# sbt version (default: from project/build.properties if present, else latest release)
--sbt-version <version> use the specified version of sbt
--sbt-jar <path> use the specified jar as the sbt launcher
# java version (default: java from PATH, currently openjdk version "17.0.2" 2022-01-18)
--java-home <path> alternate JAVA_HOME
# jvm options and output control
JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF-8"
.jvmopts if this file exists in the current directory, its contents
are appended to JAVA_OPTS
SBT_OPTS environment variable, if unset uses ""
.sbtopts if this file exists in the current directory, its contents
are prepended to the runner args
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
-Dkey=val pass -Dkey=val directly to the java runtime
-J-X pass option -X directly to the java runtime
(-J is stripped)
In the case of duplicated or conflicting options, the order above
shows precedence: JAVA_OPTS lowest, command line options highest.
What's Next
Now that we have a development environment set up, let's try creating a simple program.
- Next Step: Creating the first program in Scala
C C++ C# Clojure Crystal D Dart Erlang F# Go Haskell Java Javascript Julia Kotlin Lua Python Rust Swift Typescript