Scala Error Compiling SBT component with intellij
Asked Answered
Y

11

26

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 downgrade my scala-compiler version but this didn't help.

Yeah answered 6/8, 2015 at 9:19 Comment(7)
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: #21498306Queensland
sbt version 0.13.8 scala version 2.10.4 (from cmd)Yeah
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 availableQueensland
what was there under scala was scala 2.11 i removed it and still this doesn't work...Yeah
Well 2.11 is newer than 2.10, so that shouldn't be the problemQueensland
@Queensland your comment should be the solution to this.Mchail
I had the same problem, and it has been solved by changing from java 14 to java 1.8Plasmagel
G
33

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

Googly answered 14/3, 2018 at 17:43 Comment(1)
I faced with the same issue. However by going back to JDK1.6.0_181, the issue remains. Anyone knows why?Ynes
B
17

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.

Bauble answered 14/4, 2020 at 2:59 Comment(2)
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...Cuthbert
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 neededApsis
P
16

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.

Psychopathy answered 9/2, 2022 at 10:42 Comment(1)
Thanks for also mentioning the Scala Compile Server. This resolved the issue for me.Stormy
S
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
Sequestered answered 12/2, 2021 at 12:43 Comment(1)
Does not work with openJDK 11 as of date.Limitative
C
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,

Chimere answered 24/2, 2023 at 4:48 Comment(0)
M
1

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

Try to re-import the project to Intellij.

Motorway answered 6/8, 2015 at 14:22 Comment(1)
Indeed, the compilation already worked on the console but IntelliJ would not compile, and a re-import solved the issue for me.Daren
Y
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

Yeah answered 9/8, 2015 at 9:5 Comment(0)
S
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.

Stuckey answered 7/10, 2020 at 14:37 Comment(0)
M
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

Mickeymicki answered 5/9, 2022 at 22:20 Comment(0)
P
0

I met the same error when I run the old project https://github.com/dpp/simply_lift

it was from 2010.. I must revert my java to 1.7 and update the Scala version from 2.11.6 to 2.11.12 , add it to Project Settings-> Modules

Then I can start the project ...

enter image description here

Phillisphilly answered 10/10, 2023 at 22:4 Comment(0)
U
-1

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

Unstring answered 4/9, 2019 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.