25

I'm trying to compile a mixed java-scala code using intelliJ 14.1.4

but it keeps giving me this error:

Error Compiling SBT component 'compiler-interface-2.9.2-52.0'

I have tried to down grade my scala-compiler version but this didn't helped.

any help would be appreciated.

yole
  • 92,896
  • 20
  • 260
  • 197
vlady
  • 477
  • 1
  • 7
  • 14
  • What versions of scala and sbt are you using? Looks like Scala 2.9.x so you could try upgrading to Scala 2.10. OP here had a similar problem with an older version: http://stackoverflow.com/questions/21497806/intellij-idea-13-error-compiling-sbt-component – thwiegan Aug 06 '15 at 09:34
  • sbt version 0.13.8 scala version 2.10.4 (from cmd) – vlady Aug 06 '15 at 09:38
  • Maybe your IntelliJ or the Project you are trying to compile still run on an older version. On your project you can check under Project Structure -> Global Libraries or in your build.sbt, if available – thwiegan Aug 06 '15 at 09:42
  • what was there under scala was scala 2.11 i removed it and still this doesn't work... – vlady Aug 06 '15 at 12:16
  • Well 2.11 is newer than 2.10, so that shouldn't be the problem – thwiegan Aug 06 '15 at 12:18
  • @thwiegan your comment should be the solution to this. – ArticIceJuice Jan 16 '19 at 01:13
  • I had the same problem, and it has been solved by changing from java 14 to java 1.8 – Igor Tiulkanov Mar 01 '21 at 13:39

10 Answers10

30

I had the same issue:

Error Compiling the SBT component 'compiler-interface-2.11.8-53.0'

I was running Java 9,jdk-9.0.4, I fixed this by going back to Java 8, jdk1.8.0_161

Derlin
  • 9,572
  • 2
  • 32
  • 53
Andre Odendaal
  • 759
  • 7
  • 7
  • I faced with the same issue. However by going back to JDK1.6.0_181, the issue remains. Anyone knows why? – chucklai Jul 24 '21 at 05:34
16

this confuse me a lot

in idea you have two jdk setup

one is

enter image description here

another is

enter image description here

you need to set this two both to jdk1.8 or will always be conflict with your scala.

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
Amy
  • 169
  • 1
  • 2
  • 1
    For people who don't want to click through, this is a reminder that the project JDK and run configuration both need to match (and be the right version for your project). Even 6 years later this was helpful... – cbmanica Sep 29 '20 at 20:23
  • Once again, if you don't want to open images and search for settings, here are the steps---> Right click on your project name --> Click on 'Open Module Settings' --> Under project settings withing Project and Module change the setting back to JDK needed – Nav Oct 28 '20 at 14:29
14

To add to Amy's and other answers, there are three places where JDK is involved. The first two are in the Project Settings, the third is Settings -> Build, Execution, Deployment -> Compiler -> Scala Compiler -> Scala Compile Server (if enabled). If this problem arises, check these three are the same.

merinoff
  • 311
  • 3
  • 7
12

Make sure you have the JDK-1.8 set in the following places.

Project Settings -> Project -> Project SDK
Project Settings -> Modules -> Dependencies -> Module SDK 

Add/Select JDK-1.8 in

Project Settings -> SDKs
Murali Mopuru
  • 6,086
  • 5
  • 33
  • 51
8

Make sure you have the JDK-1.8 set in the following places. Project Settings -> Project -> Project SDK Project Settings -> Modules -> Dependencies -> Module SDK Add/Select JDK-1.8 in

Project Settings -> SDKs

The first two are in the Project Settings, the third is Settings -> Build, Execution, Deployment -> Compiler -> Scala Compiler -> Scala Compile Server (if enabled). If this problem arises, check these three are the same.

Make Sure that Java versions are same every where,

abhilash ks
  • 81
  • 1
  • 1
1

Don't believe to Intellij's compiler. Prefer compiling them in a console.

Try to re-import the project to Intellij.

Waldemar Wosiński
  • 1,490
  • 17
  • 28
  • Indeed, the compilation already worked on the console but IntelliJ would not compile, and a re-import solved the issue for me. – Christoph Jul 17 '17 at 15:19
1

Solved.

The issue was due to 2 different dependencies, which imported 2 different scala versions, and then scala 2.11 was compiled with scala 2.9 which led to the error.

maven dependencyManagement solved it for me

vlady
  • 477
  • 1
  • 7
  • 14
1

This problem occurs due to incompatibility in versions of the libraries used. The solution is to ensure that java version, scala version, any other library version are all compatible with each other. mvnrepository can be used for checking.

SD3
  • 196
  • 2
  • 6
0

Also, please make sure you are using compatible Scala and Jdk version. like - JDK-Scala Version compatibility table

Please refer - https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html

-1

File --> Invalidate caches/restart was also needed for me in addition to fixing libraries.

juanignaciosl
  • 3,435
  • 2
  • 28
  • 28