0

I follow the tutorial of sbt Hello World, and I mkdir with hw.scala and build.sbt in it.

then I type sbt run and execute it, then occur a error

java.lang.NoClassDefFoundError: scala/Function1

But if I change the scalaVersion in build.sbt, for example, I change it to 2.11.7 and it will be successful output "Hi" with the example code.

How to solve this error? Thanks everyone helping me.

the error:

  • [info] 'compiler-interface' not yet compiled for Scala 2.11.8. Compiling...
  • [info] Resolving org.scala-sbt#interface;0.13.13 ...
  • [trace] Stack trace suppressed: run last compile:compileIncremental for the full output.
  • [error] (compile:compileIncremental) java.lang.NoClassDefFoundError: scala/Function1

and my code build.sbt, hw.scala:

lazy val root = (project in file(".")).
  settings(
    name := "hello",
    version := "0.1.0",
    scalaVersion := "2.11.8"
  )

-

object Hi { def main(args: Array[String]) = println("Hi!") }
jwvh
  • 50,871
  • 7
  • 38
  • 64
g1eny0ung
  • 1,761
  • 3
  • 14
  • 17
  • Code you posted works fine for me – dlite922 Nov 18 '16 at 21:00
  • @dlite922 I delete .ivy2/ and .sbt/ and reinstall sbt, then I try it again, it also have this error. My laptop is ubuntu 16.04 and I also install scala 2.12.0 from [http://www.scala-lang.org/download/](http://www.scala-lang.org/download/) – g1eny0ung Nov 19 '16 at 01:21
  • It could be mismatched versions of sbt and scala. Make sure your sbt version and scala version get along – dlite922 Nov 20 '16 at 21:29
  • @dlite922 e.., now I haven't found the solution, my sbt version is 0.13.13, is this version not compatible with scala 2.11.8 ? is this can related to [Does sbt build against scala 2.11?](http://stackoverflow.com/questions/23282469/does-sbt-build-against-scala-2-11/)? – g1eny0ung Nov 21 '16 at 07:47
  • I ran your code with SBT 0.13.8 and Scala 2.11.7, so something else might be wrong with your system. Could you try it on a virtual box ubuntu? – dlite922 Nov 21 '16 at 16:31
  • I will try it, thanks for you help^_^ – g1eny0ung Nov 22 '16 at 00:33

0 Answers0