Scala compiler library not showing in intellij community edition v15 - scala

I have the Scala and SBT plugins enabled (I tried switching off the SBT plugin as well to test) - when I import an existing Play framework project, go to "Project Structure", go to "Modules", select module, then "Dependencies" tab - I do not see the Scala Compiler library options at all over there (I have JDK8 and it is selected as the IDE project JVM and I have Scala and SBT on the computer - Scala v2.11.7 & SBT v0.13.9). Any ideas on what I might be missing? I only see the JDK and Module source under Dependencies but no Scala compiler options.
I am familiar with the IntelliJ blog referencing how to import a play framework project: https://www.jetbrains.com/idea/help/getting-started-with-play-2-x.html

I am only showing the scala sdk in my Global Libraries tab in Project Structure.
Are you not able to build your project in IntelliJ?

Related

Run Scala Dotty project using Intellij IDE

I created a basic Scala Dotty project using Dotty template and import the project to IntelliJ IDE.
Everything works fine when I use the sbt command line.
When I try to build or run it inside IntelliJ IDE, I got following errors:
Error:scalac: Multiple 'scala-library*.jar' files (scala-library-0.9.0-RC1.jar, scala-library-2.12.6.jar) in Scala compiler classpath in Scala SDK sbt: ch.epfl.lamp:dotty-library_0.9:0.9.0-RC1:jar
Any ideas how to solve this?
IDE support for Dotty
Currently, the only IDE we officially support is Visual Studio Code.
Anyway when you import a project to IntelliJ IDEA check "use sbt shell". At least for me after that a test project compiles and runs with Ctrl+Shift+F10.
It's possible that not everything will work. For example Dotty macros don't but if I compile and run manually then they do.

Can not download jars when building scala project with sbteclipse?

As shown in the picture, when I build scala project with sbteclipse and import to eclipse, when changing build.sbt , jars are downloaded to my computer but not to scalaProject. I do not know why. Can someone help me?
scala version: 2.11.8
sbt version: 0.13.15
stbeclipse:5.1.0
I assume that you're using the Scala IDE plugin for Eclipse, correct?
The sbteclipse SBT plugin merely provides a command to generate an Eclipse Scala project from the SBT build. Before using Eclipse, you're supposed to issue the following command (from the command line) to SBT:
sbt eclipse
This should generate the project files for your Eclipse project. After executing this command, you can open your project using Eclipse (with the Scala IDE plugin).
Note that, at present, the Scala IDE Eclipse plugin does not support SBT build files. That is, if you change your SBT build file, then Eclipse will be none the wiser, until you re-run the above command.
You might want to consider switching to IntelliJ IDEA (instead of Eclipse) which has a full-featured Scala plugin that fully supports SBT builds, including downloading any dependencies. For my money (both IDEs are free) IntelliJ is light-years ahead of Eclipse for Scala development.

`Cannot find symbol` in IntelliJ 14

I have use the IntelliJ Scala plugin before, in 13 and 13.1. I upgraded to 14, and it doesn't work anymore for my SBT project.
For all Scala standard lib stuff, I see errors like "Cannot find symbol scala.Option".
at scala project, compiler error - Cannot resolve symbol List? says I need to have the Scala facet for my module. I looked in facets, and Scala wasn't an option.
I've uninstalled IntelliJ and the Scala plugin and my settings and the projects files multiple times, but still happens.
How do I fix this?
the new scala plugin for intellij 14 removed the facet and replaced it with Scala SDK library, see blog
for sbt project, I guess the best bet is to re-create your project by:
File -> open -> select the build.sbt of your project in popup -> delete existing project and import
I had a similar issue when a Java module calls an Scala object. The issue was from the wrong setup in Source Folders; the Scala source was in src/main/scala/..., but in the Project Structure, the Source Folders were setup as src by default. When I changed it as src/main/scala, the Java module can find the Scala object correctly.
I fixed this by using the nightly builds of the Scala plugin.
The fixes have now been incorporated into the stable versions.
In my case i just had to reload the IDE...

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?
Open File -> Project Structures -> Libraries, remove any scala sdk in it, e.g. scala-sdk-2.11.8 in the following image.
Click on +, then Scala SDK.
Select the right Scala SDK from the list, for me, it's Ivy-Scala-2.11.8 shown in the picture.
Select the current project(mine is spark-test), click OK.
Then click OK to close it.
Run again, it should work now.
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.
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.
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
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:

how to use a different version of scala library with scala ide 3.0.2?

I've got the newest Scala IDE (3.0.2) and I want to compile my stuff with Scala 2.9.3. I've added that version of Scala as a Maven dependency and removed the default 2.10.0 that the IDE bundles with the new project (not my system Scala version, by the way!). The IDE then tells me Scala is not on the build path, even when I add in the jars to the build path. When I try to add a "Scala Library" through that dialogue, it doesn't give me any options and adds 2.10.0. I've gone through the project settings, and would have expected to see a "Scala version" option, but there isn't (only a "Java version" option.)
My question is this:
How do I add a different version of Scala as the Scala library in Scala IDE 3.0.2 ?
Thanks!
I asked a similar question a while back. Short answer is, you can't.
My post:
Scala-IDE 3.0: 2.9.2 -> 2.10.0