I am relatively new to Scala and Akka, transitioning from a Java, Spring, and REST API background. Currently, I am working through the Akka Actors Quickstart with Scala tutorial.
Upon attempting to run the Hello World example for Scala, following the provided steps, I encountered an issue when executing sbt reStart
. The error message is as follows:
akka-quickstart-scala[ERROR] Error: A JNI error has occurred, please check your installation and try again
akka-quickstart-scala[ERROR] Exception in thread "main" java.lang.UnsupportedClassVersionError: akka/actor/typed/ActorSystem has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
After researching, I found suggestions to upgrade the JRE to version 11, but due to constraints, I cannot do so at the moment. Attempting to compile the code in Java 8 using scalac AkkaQuickstart.scala
resulted in the following error:
AkkaQuickstart.scala:5: error: not found: object akka
import http://akka.actor.typed.ActorRef
Given that I'm a novice in Akka and Scala, and unable to upgrade the Java version, I am seeking guidance on resolving this version mismatch and compilation error. Any assistance would be greatly appreciated.
Thanks in advance.
Akka 2.9 - Support for Java 8 removed
Support for Java 8 removed
The published artifacts are targeting Java 11, and later. Supported Java versions are 11 and 17.
The PR to drop jdk 8 support was merged
Akka 2.9 - Support for Scala 2.12 removed
Support for Scala 2.12 removed
The published artifacts are targeting Scala 2.13 and Scala 3.3.
Which means, if you only are able to run your projects using jdk 8, the latest version of akka you can use is 2.8.x.
I was able to run locally the following dummy akka hello world
build.sbt
ThisBuild / scalaVersion := "2.13.12"
lazy val root = (project in file("."))
.settings(
name := "akka-dummy-hello-world",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor-typed" % "2.8.5"
)
)
Main.scala
import akka.actor.typed.ActorSystem
import akka.actor.typed.scaladsl.Behaviors
object Main {
def main(args: Array[String]): Unit = {
val empty = Behaviors.setup[Any] { _ =>
println("hello akka dummy")
Behaviors.empty
}
val actorSystem = ActorSystem(empty, "akka-dummy-hello-world")
actorSystem.terminate()
}
}