简体   繁体   中英

Sbt project loading error - “java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter”

In IntelliJ Idea on OS XI have a project (a Coursera assignment file, with no homework functions implemented yet) that is compiling in Idea, but when I try to load it in sbt in the terminal from the project root folder, using just "sbt", I get the error:

[info] Loading project definition from <omitted>/calculator/project  
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter  
   at sbt.inc.TextAnalysisFormat$ObjectStringifier$$anonfun$34.apply(TextAnalysisFormat.scala:336)
<trace omitted>  
[error] (compile:readAnalysis) java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter  
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

build.sbt scalaVersion is 2.11.7; in the Idea project structure window Global Libraries tab, I have scala-sdk-2.12.4, and in the SDKs and Project tabs, I have Java 1.8.

Brew tells me I have sbt 1.0.4, but when I run sbt --about from the project folder, it shows me:

[info] This is sbt 0.13.9  
[info] No project is currently loaded  
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.5

followed by an attempt to load the project and the resulting error. The build.properties file in the project has sbt version 0.13.9, but why does the sbt about info show Scala 2.10.5?

I have both Java 8 and Java 9 installed on my system (via brew cask) - is it possible that sbt is for some reason using Java 9 instead of Java 8, and if so, how would I check and fix that? The install command for Java 9 was "brew cask install java", while for Java 8 it was "brew cask install java8".

Edit: "java -version" command shows:

java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

Scala and Java 9 have some interaction problems. I uninstalled Java 9, since I don't need it instead of Java 8 for anything right now, and afterward the project loaded without error.

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