ScalaFX with JavaFX binaries inclusion in sbt (Scala 2.13, Java 8)

53 views
Skip to first unread message

Bene Volent

unread,
Jan 5, 2020, 9:48:36 PM1/5/20
to ScalaFX Users
Below (from https://github.com/scalafx/scalafx) it says with Java 11, JavaFX binaries need to be explicitly added to a project.

Question: Is this relevant if I'd be running Java 8 with Scala 2.13.1 (preliminary simple test did not show any symptoms)?



ScalaFX Dependencies

ScalaFX 12 is the current actively maintained version. ScalaFX 12 is intended to support Java 11 and newer. Staring with Java 11 JavaFX is no longer part of Java distribution. In addition to ScalaFX, JavaFX binaries needs to be explicitly added to a project. JavaFX binaries depend on operating system used. Add following to SBT configuration:

// Add dependency on ScalaFX library
libraryDependencies += "org.scalafx" %% "scalafx" % "12.0.2-R18"

// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
  case n if n.startsWith("Linux")   => "linux"
  case n if n.startsWith("Mac")     => "mac"
  case n if n.startsWith("Windows") => "win"
  case _ => throw new Exception("Unknown platform!")
}

// Add dependency on JavaFX libraries, OS dependent
lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
libraryDependencies ++= javaFXModules.map( m =>
  "org.openjfx" % s"javafx-$m" % "12.0.2" classifier osName
)
Reply all
Reply to author
Forward
0 new messages