brent
brent

Reputation: 1105

Error building Intellij Scala Plugin

I am trying to follow the instructions at

https://confluence.jetbrains.com/display/SCA/Setting+up+Scala+plugin+project+in+IntelliJ+IDEA

I am using Idea 14.1.14. Have downloaded the sources and downloadIdea. And after importing the project set the Project SDK to 1.7.

Not sure if the above is enough info to go on; but on make project I get the below error; is it possible to guess at what I've got incorrect?

Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar(java/lang/Object.class)
Error:scalac: Error: object scala in compiler mirror not found.
scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
    at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
    at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
    at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:173)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:161)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:161)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:162)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass(Definitions.scala:162)
    at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1377)
    at scala.tools.nsc.Global$Run.<init>(Global.scala:1229)
    at xsbt.CachedCompiler0$$anon$2.<init>(CompilerInterface.scala:116)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:116)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
    at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
    at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Warning:scalac: No 'scala-library*.jar' in module dependencies [compiler_settings]

Upvotes: 6

Views: 14672

Answers (7)

Chris Gong
Chris Gong

Reputation: 8229

Double-Check JDK Compatibility

I encountered this issue when the Java SDK being used by my IntelliJ project was too "new" for the version of Scala I was using. For example, IntelliJ defaulted to using Java 12 for my project when my project was using Scala version 2.11.8. However, according to the documentation, the minimum required Scala version for JDK 11 is 2.11.12; therefore, I resolved this problem by changing the JDK used in IntelliJ to Java 8 by going to File -> Project Structure -> Project -> Project SDK

Upvotes: 0

HHH
HHH

Reputation: 310

enter image description here

better also check here. It solved my own building errors

Upvotes: 1

Lakshya Sharma
Lakshya Sharma

Reputation: 21

Only Java 8 JDK version should be used along side scala. Not even higher JDK versions.

Upvotes: 1

iloveindia
iloveindia

Reputation: 31

I have faced a similar issue recently even after having the compatible versions of java,sbt and scala SDK but found few reasons why we get this error when we importing sbt project into Intellij.

  1. Check the scala-SDK is present in the global libraries under File->Project Structure -> Global Libraries.

Please find the below screenshot.

Intellij global library settings

  1. Even after fixing the first issue you still face this issue. Then look for the external dependencies which you have placed under /lib folder check the checksum of that jar if possible are make sure it has the right size. This should solve the issue.

external libarires

Apart from the above issue, you might end up with dependencies source linking issues in the code when you open the project in IntelliJ. This is because of the additional root modules which are present under File -> Project modules -> modules. In the modules panel, you will see projectxxx-src and projectxx-test additional to projexctxx-process and projectxx-process-build. So remove the projectxx-src and projectxx-test.

Remove additional modules

Upvotes: 3

mahmoud mehdi
mahmoud mehdi

Reputation: 1590

In my case, I had to specify the correct JDK home path in the Project structure -> SDKs.

Since my JAVA_HOME variable was not set yet, Intellij was taking a default value which doesn't exist.

Replace the JDK Home Path by the the right path of the JDK (in my case it was the following : /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home)

Replace 'adoptopenjdk-8.jdk' by your folders' name (might be jdk_1.8.0_xxx.jdk)

I hope it helps.

Upvotes: 0

Adam
Adam

Reputation: 623

You have to have Java 8 JDK for Scala to work

see the scala site for further info

Upvotes: 1

Željko Trogrlić
Željko Trogrlić

Reputation: 2895

Go to File -> Project structure -> Global libraries and add Scala SDK there. In my case, two SDKs were already present (in ivy folder) and offered for selection.

Upvotes: 14

Related Questions