简体   繁体   中英

Why should I use jdk1.8.0 instead of jdk-17?

I am studying Scala, with IntelliJ IDEA. Project SDK was always jdk-17, everything was OK, until now.

I began practicing in actors (Akka in action using Scala). Problems (like scalac: Error: Error compiling the sbt component 'compiler-interface-2.11.8-61.0') started compiling book examples. The advise was to use jdk1.8.0, and it helped. I don't understand why should I use jdk1.8.0 instead of jdk-17? 17 > 1.8.0? Is jdk1.8.0_XXX is actual SDK?

build.sbt

name := "fault-tolerance"

version := "1.0"

organization := "com.manning"

scalaVersion := "2.11.8"

libraryDependencies ++= {
  val akkaVersion = "2.4.19"
  Seq(
    "com.typesafe.akka"       %%  "akka-actor"                     % akkaVersion,
    "com.typesafe.akka"       %%  "akka-slf4j"                     % akkaVersion,
    "com.typesafe.akka"       %%  "akka-testkit"                   % akkaVersion   % "test",
    "org.scalatest"           %% "scalatest"                       % "3.0.0"       % "test"
  )
}

According to the Scala JDK compatibility list :

JDK version Minimum Scala versions
18 2.13.7, 2.12.15
17 2.13.6, 2.12.15
11 2.13.0, 2.12.4, 2.11.12
8 2.13.0, 2.12.0, 2.11.0, 2.10.2

You need to use at least Scala 2.12.15 if you want to work with JDK 17.

Your project however specifies Scala version 2.11.8, which doesn't support any JDK version after 1.8.

So you either need to

  • upgrade your project to work with Scala 2.12.15 if you want to use Java 17
  • upgrade your project to work with Scala 2.11.12 if you want to use Java 11
  • otherwise you are stuck with Java 8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM