0

i was compiling my scalafx code in intellij in a sbt file and they kept showing me this error, please help i tried everything but its still not working

[info] Updating
[info] Resolved  dependencies
[warn]
[warn]  Note: Unresolved dependencies path:
[error] stack trace is suppressed; run last update for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading org.scalafx:scalafx_2.13:8.0.192-R14
[error]   Not found
[error]   Not found
[error]   not found: /Users/xxxxx/.ivy2/local/org.scalafx/scalafx_2.13/8.0.192-R14/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scalafx/scalafx_2.13/8.0.192-R14/scalafx_2.13-8.0.192-R14.pom

this is my built.sbt

name := "practical4b"

version := "0.1"

scalaVersion := "2.13.1"

// https://mvnrepository.com/artifact/org.scalafx/scalafx
libraryDependencies += "org.scalafx"%%"scalafx"%"8.0.192-R14"
Mike Allen
  • 8,139
  • 2
  • 24
  • 46
lamecoder
  • 1
  • 2

1 Answers1

3

The problem here is that there is no release of ScalaFX 8/R14 that works with Scala 2.13.

Each Scala release, with the exception of bug-fix releases, has different binary compatibility requirements. So if you're using a Scala-built library with, say, Scala 2.13, you need the build of that library created for the same Scala version. Libraries created from Java code typically have binary compatibility with any version of Scala.

To determine which Scala versions are supported, they are listed in the column under Scala on Maven Central (the site linked to in your code above the libraryDependencies property): enter image description here

You can resolve this problem either by switching to Scala 2.12, by changing the Scala version as follows:

scalaVersion := "2.12.12"

Or, you can use a more recent version of ScalaFX, that will work with Scala 2.13, by changing the library dependency as follows:

libraryDependencies += "org.scalafx" %% "scalafx" % "12.0.2-R18"

to use R18, or:

libraryDependencies += "org.scalafx" %% "scalafx" % "14-R19"

for R19.

A lot will depend upon which version of Java you are using. If you need to use Scala 2.13, with one of the more recent ScalaFX releases, I would recommend using Java 11 LTS. If you must use Java 8, then stay with the ScalaFX 8/R14 release and use Scala 2.12. Let me know if you have any questions.

Mike Allen
  • 8,139
  • 2
  • 24
  • 46
  • hello i am using the latest java 8 JDK and also scalaVersion : 2.12.11 and also `libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.192-R14"` i am receiving this error now instead Symbol 'type javafx.scene.shape.Rectangle' is missing from the classpath. [error] This symbol is required by 'class scalafx.scene.shape.Rectangle'. [error] Make sure that type Rectangle is in your classpath and check for conflicting dependencies with `-Ylog-classpath`. [error] A full rebuild may help if 'Rectangle.class' was compiled against an incompatible version of javafx.scene.shape. – lamecoder Jul 22 '20 at 19:25
  • Which release of _Java_ are you using, and does it have _JavaFX_ installed with it? (_Oracle_'s official Java 8 JRE/JDK _does_ come with _JavaFX_, but most of the _OpenJDK_ releases _don't_ provide _JavaFX_. If you upgrade to _Java 11_ (any flavor), you can guarantee that _JavaFX_ isn't installed, but _ScalaFX_'s dependencies will download it from _Maven Central_.) – Mike Allen Jul 22 '20 at 19:30
  • @lamecoder Did you see my comment in reply? Did that work for you or do you have any further questions. Let me know... – Mike Allen Jul 25 '20 at 15:15
  • hello i am using the latest java 8 which is javac 1.8.0_261 and also sbt 2.12.11 ! i have found a solution to it and it works fine for now...... – lamecoder Jul 26 '20 at 08:29
  • `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 JavaFX dependencies` `lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", `"swing", `"web")` `libraryDependencies ++= javaFXModules.map( m=>` ` "org.openjfx" % s"javafx-$m" % "11" classifier osName` `)` – lamecoder Jul 26 '20 at 08:31
  • thanks for your help! im new to this platform so its surprising for someone to help out – lamecoder Jul 26 '20 at 08:31