java: javacTask: source release 8 requires target release 1.8 (sbt project)

I have an sbt project:

name := "experiments"

scalaVersion := "2.10.4"

javacOptions ++= Seq("-source", "1.8","-target","1.8")

version := "1.0"


This imports ok and I can see in the java compiler settings , Project Bytecode level is 1.8 and additional compiler parameters are -source 1.8 -target 1.8

But still when I compile the project, I get this error:

java: javacTask: source release 8 requires target release 1.8 (sbt project)

Any ideas what might be wrong?

1 comment

Hi! Currently it's not always obvious how to determine intended JDK for an SBT project. While I'm unable to reproduce the problem, here's what you may check to resolve the error:

  • in Project Structure / Platform Settings / SDKs: JDK 1.8 is present, JDK home path really points to an existing JDK 8
  • in Project Structure / Project Settings / Project: Project SDK is JDK 1.8, Project language level is 8
  • in Project Structure / Project Settings / Modules: all modules inherit project SDK (Dependencies / Module SDK)
  • in Settings / Project Settings / Compiler / Java Compiler: Project bytecode version is either blank or 1.8, no per-module bytecode versions are configured


There was a similar report at StackOverflow (Maven-related, though), so you may also verify .idea/compiler.xml file ("target" attribute value).

Please tell us whether all that will help.

0

Please sign in to leave a comment.