Scala and SBT install on Debian with Java 8

2019-05-31 05:01发布

问题:

I have java 8 server runtime on Debian.

Tried: dpkg -i scala-2.11.7.deb

scala depends on java6-runtime-headless; however: Package java6-runtime-headless is not installed.

But is ok: scala -version Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL

Now installing SBT from bintray repo:

My Java 8 is deactivated, installs open openjdk-7-* ...

Have to "apt-get purge openjdk-7-*" (wrong way)

EDIT: Problem corrected with: update-alternatives --config java

回答1:

Here is the list of commands that I used to install in a clean Debian Jessie instance created using Vagrant:

Install Java 8

sudo add-apt-repository ppa:webupd8team/java

Edit the file /etc/apt/sources.list.d/webupd8team-java-jessie.list to replace jessie with trusty so that it will have the following line:

deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

And then execute:

sudo apt-get update
sudo apt-get install oracle-java8-installer

Confirming that Java 8 is properly installed:

java -version

Which outputs:

java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

Installing Scala 2.11.7:

wget -c www.scala-lang.org/files/archive/scala-2.11.7.deb
sudo dpkg -i scala-2.11.7.deb

This works fine to me and, just to confirm that I'm using the most recent version, I've executed:

sudo apt-get update
sudo apt-get install scala

And then:

scala -version

Which outputs:

Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL

Install SBT:

wget -c https://bintray.com/artifact/download/sbt/debian/sbt-0.13.9.deb
sudo dpkg -i sbt-0.13.9.deb

Everything works as expected and then I've executed the following commands to ensure that I'm using the most recent version of SBT:

sudo apt-get update
sudo apt-get install sbt

At this point, Java 8, Scala and SBT were successfully installed on my machine.