Scala Compiliation error with intellij

23,269

Solution 1

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

Solution 2

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.

Solution 3

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

Solution 4

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

Solution 5

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.

Share:
23,269
vlady
Author by

vlady

Updated on February 10, 2022

Comments

  • vlady
    vlady about 2 years

    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.

  • Christoph
    Christoph almost 7 years
    Indeed, the compilation already worked on the console but IntelliJ would not compile, and a re-import solved the issue for me.
  • cbmanica
    cbmanica over 3 years
    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...
  • Nav
    Nav over 3 years
    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
  • Shiwakant Bharti
    Shiwakant Bharti about 3 years
    Does not work with openJDK 11 as of date.
  • chucklai
    chucklai almost 3 years
    I faced with the same issue. However by going back to JDK1.6.0_181, the issue remains. Anyone knows why?