1. 下载安装

1.1 一键安装

来到官网
https://www.scala-lang.org/download/

找到你的平台
复制他给你的指令

curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup

有个要你输入Y确认
等一等就好了

它从github下载的,请保持网络良好

刷新一下环境变量

source ~/.profile
source ~/.bash_profile

你可能想知道它安装到哪里去了,它在这$PATH:/root/.local/share/coursier/bin,打开~/.profile就能看到了,但这不是scala的目录,是cs的

1.2 手动安装

来到官网
https://github.com/lampepfl/dotty/releases

找到某发行版的Assetsscala3-3.3.1.tar.gz

cd /user/
# 下载
wget https://github.com/lampepfl/dotty/releases/download/3.3.1/scala3-3.3.1.tar.gz
# 解压
tar -zxvf scala3-3.3.1.tar.gz
# 删安装包
rm -f scala3-3.3.1.tar.gz

添加环境变量

vim /etc/profile

末尾添加

#SCALA_HOME
export SCALA_HOME=/usr/scala3-3.3.1
export PATH=$PATH:$SCALA_HOME/bin:$SCALA_HOME
source /etc/profile

3. 测试

输入

scala -version

有下面这样的输出就好了

Scala code runner version 3.3.1 -- Copyright 2002-2023, LAMP/EPFL