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

℡╲_俬逩灬. 提交于 2019-11-30 04:14:34

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.

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

  2. Click on +, then Scala SDK.

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

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

  5. Then click OK to close it.

  6. Run again, it should work now.

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).

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!