Jonathan Schneider
Jonathan Schneider

Reputation: 27727

Error: scala: No 'scala-library*.jar' in Scala compiler library

Environment: Play 2.3.0/Scala 2.11.1/IntelliJ 13.1

I used Typesafe Activator 1.2.1 to create a new project with Scala 2.11.1. After the project was created, I ran gen-idea. The generated IDEA project fails to compile with the error:

Error: scala: No 'scala-library*.jar' in Scala compiler library in test

Am I doing something wrong? Workaround?

enter image description here

Upvotes: 47

Views: 52118

Answers (11)

Adrika Gupta
Adrika Gupta

Reputation: 41

I did the following and it worked for me -

  1. Click on 'Maven' in the right panel
  2. Click on 'Reload All Maven projects'

Upvotes: 0

Oleksandr Yefymov
Oleksandr Yefymov

Reputation: 6509

I had same issue for Maven multimodule project unexpectedly.

It happens with IntelliJ 2023.1.3.

Solution: simple re-import of Maven project helped.

Upvotes: 0

Mike
Mike

Reputation: 91

it looks like my answer is 9 years late, but the previous answers didn't work for me when I faced such a problem, so I'll leave my solution here.

File > Project structure > Global Libraries > in my case it was scala-sdk-2.13.8 > press minus sign (remove library) > press plus sign > select SDK that corresponds to your scala version ( ex. scala-sdk-2.12.10 in my case \ find you version in pom.xml file) > OK > Applay\OK

enter image description here

Upvotes: 2

sennett
sennett

Reputation: 8424

I'm an absolute Scala beginner. I was wanting to get up and running. I needed to create a Scala project, not a Java project with Scala library:

screenshot showing correct buttons to click

Upvotes: 0

crifan
crifan

Reputation: 14318

now is 2021 year, in Mac, use IntelliJ to run scala:

  • core logic
    • Mac: brew install scala
    • IntelliJ: open *.scala file, then according notice to auto config java JDK and Scala SDK
  • detailed steps: pls refer another post's answer

Upvotes: 0

Searene
Searene

Reputation: 27544

  1. Open File -> Project Structures -> Libraries, remove any scala sdk in it, e.g. scala-sdk-2.11.8 in the following image. enter image description here

  2. Click on +, then Scala SDK. enter image description here

  3. Select the right Scala SDK from the list, for me, it's Ivy-Scala-2.11.8 shown in the picture.enter image description here

  4. Select the current project(mine is spark-test), click OK. enter image description here

  5. Then click OK to close it. enter image description here

  6. Run again, it should work now.

Upvotes: 63

ketankk
ketankk

Reputation: 2664

I had the same issue.

If you are building your project using external sbt i.e sbt compile then it will create or add dependencies in libraries(all external dependency also) and scala sdk will be added as SBT:scala* based on version of your scala. So you can remove SDK with SBT as prefix and add proper SDK through Intellij.

File->Project Structure->Libraries

Remove SBT SDK and add it manually.

Upvotes: 1

wiseco68
wiseco68

Reputation: 41

For me with IDEA 12, I fixed this issue when I unchecked the box for "Use external build" in Settings.Compiler.

Upvotes: 0

Alex Shcherbyna
Alex Shcherbyna

Reputation: 301

For IDEA 15 and project exported from Activator 1.3.5 only Russell's solution helped at the moment. I have fixed scala compiler library with adding 3 libraries located in ~/.sbt/boot/scala-2.11.1/lib to library's compiler classpath and classes. After indexing project I moved this library to global libraries of IDEA and it was saved there.

Upvotes: 1

Russell
Russell

Reputation: 2076

I had the same issue with the .idea files generated by ./activator idea with play 2.3. A quick fix is to look in "Project Structure->modules" and note the name of the compiler library. For me it was "SBT: scala2.11.1". The look in "Project Structure->Libraries" and check the contents of this library. It should contain scala-compiler.jar, scala-library.jar, scala-reflect.jar. If this libraries are not present, add them (in my case they are located in ~/.sbt/boot/scala-2.11.1/lib).

Upvotes: 7

Vladimir Matveev
Vladimir Matveev

Reputation: 127711

Since IDEA 13 you should use SBT support which is bundled with Scala plugin.

With it there is no need to add third-party SBT plugins and run special commands; just import the project using "File -> Import project..." menu item, and it will automatically load SBT project structure and its dependencies.

Upvotes: 19

Related Questions