在新的ubuntu机器上安装jdk / sbt

时间:2017-11-13 22:34:51

标签: java scala ubuntu sbt

我试图在AWS上的新Ubuntu 16.04计算机上安装SBT。我之前从未遇到过安装问题(以下说明),但我现在就是。

我收到此错误..." 您拥有的Java安装不是最新的 至少需要1.6+版本,你有版本1.8 "

似乎令人困惑,因为1.8似乎满足1.6+要求。

引用

scala - https://www.scala-lang.org/documentation/getting-started-sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html

sbt - http://www.scala-sbt.org/1.0/docs/Installing-sbt-on-Linux.html

sudo apt-get update 

java -version
# The program 'java' can be found in the following packages:
#  * default-jre
#  * gcj-5-jre-headless
#  * openjdk-8-jre-headless
#  * gcj-4.8-jre-headless
#  * gcj-4.9-jre-headless
#  * openjdk-9-jre-headless
# Try: sudo apt install <selected package>

sudo apt-get install openjdk-8-jdk -y

java -version
# openjdk version "1.8.0_151"
# OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
# OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt

sbt
# /usr/share/sbt/bin/sbt-launch-lib.bash: line 207: bc: command not found

# The java installation you have is not up to date
# requires at least version 1.6+, you have
# version 1.8

# Please go to http://www.java.com/getjava/ and download
# a valid Java Runtime and install before running .

1 个答案:

答案 0 :(得分:5)

查看设置的来源,它使用bc对java版本号进行算术检查,但无法运行bc

https://github.com/sbt/sbt-launcher-package/blob/master/src/universal/bin/sbt-launch-lib.bash#L207

您可以使用bc安装apt install bc