Reputation:
I try to compile a simple object in IntelliJ:
object Test02 {
def main(args: Array[String]) {
println("Hello World");
}
}
I got this message:
Error:scalac: Scala compiler JARs not found (module 'scala02'):
E:\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.11.8.jar,
E:\.ivy2\cache\org.scala-lang\scala-compiler\jars\scala-compiler-2.11.8.jar,
E:\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.11.8.jar
I checked the Project Structure and checked the modules. Modules are located here:
C:/Users/asus1/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.8.jar
How Can I change E: to C:/Users/asus1/ ?
Do I need to move all to E: ?
How people manage when the project and the jar are in different location ?
It seems a big bug of IntellJ ...?
Upvotes: 39
Views: 45954
Reputation: 21
I was having the same problem, and the solution posted from IntelliJ Developer solved the problem.
Solution:
IntelliJ IDEA 2023.2.5 (Community Edition) Go to File | Settings | Build, Execution, Deployment Under Compiler, click on Scala Compiler Look for ' Incrementality type:' and select IDEA. Apply and close .
Upvotes: 2
Reputation: 604
This could be the issue : You may have multiple maven projects linked/imported in single IntelliJ IDE window and those maven projects are using different Scala compiler versions.
First you will get multiple compiler versions detected issue, then to fix this issue if may have deleted some compiler version folder/jars from .m2 repo.
Solution : Go to maven view/tab --> Unlink maven projects from IntelliJ IDE which are using different versions of Scala , keep only projects which are using same version of Scala
Upvotes: 1
Reputation: 3536
Update @Oct 2021: This error means plugin needed an update and was solved by : goto File > Settings (Ctrl+Alt+S, Windows)/Preferences (Mac) > Plugin Search for "scala". Update.
Upvotes: 0
Reputation: 5954
For me, the following solution worked:
Go to Project Settings > Modules > Dependencies, select the Scala SDK, Edit, and correct the path of the Scala JARs:
Upvotes: 0
Reputation: 171
https://www.jetbrains.com/help/idea/invalidate-caches.html
IntelliJ IDEA caches a great number of files, therefore the system cache may become overloaded. Sometimes the caches will never be needed again, for example, if you work with frequent short-term projects.
When you invalidate the cache, IntelliJ IDEA rebuilds all projects ever run in the current version of the IDE.
Clear the system cache 1.From the main menu, select File | Invalidate Caches / Restart.
2.In the Invalidate Caches dialog, select an action. You can invalidate the caches and restart the IDE or just restart the IDE.
This worked for me.
Upvotes: 4
Reputation: 31
Open File -> Project Structure
Go to Libraries under Project Settings
Click on the minus button on the erroring Scala library
Open an existing Scala class in IntelliJ and you will see the prompt to set up Scala SDK and click on that
Upvotes: 2
Reputation: 799
In the more recent versions of IntelliJ (2020.1.1) at the time of writing this, I was able to solve this problem by removing the Scala SDK configured in the Global Libraries
section in IntelliJ and hitting File > Invalid Caches / Restart
.
I'm not sure why this solved the issue, perhaps recent versions of the IDE now have automatic detection of Scala compiler JAR files from Maven (which I'm using to build my project).
Upvotes: 14
Reputation:
SOLVED as Follow:
In project settings, you need to manually add:
Module and dependencies to JDK AND Scala JAR
In library, Add MANUALLY the JAR of Scala (IntelliJ does not add those JAR. it creates compile issues).
in Global library, check the JAR of scala are same.
There is an option to see the DEBUG in verbose mode:
https://intellij-support.jetbrains.com/hc/articles/207241085
This is very useful.
Upvotes: 5
Reputation: 1
In IntelliJ, ensure that the external libraries are present. If already present, open library settings and check the path to the jars is not in red. If in red, correct the path to the jars
Upvotes: -1
Reputation: 958
Please goto File > Settings (Ctrl+Alt+S, Windows)/Preferences (Mac) > Plugin Search for "scala". Uninstall Scala plugin.. Restart IDE. Reinstall it. Restart IDE and install the plugin. Everything works OK
Upvotes: 56
Reputation: 1060
If your project is Gradle-based, one possibility is that the project is looking for Scala libraries in the .m2 cache that don't exist. To confirm, open "Project Structure...", go to "Libraries", and examine the list for "Gradle: org.scala-lang:..." that contain errors related to missing files.
If this is the issue, simply re-import the project from scratch.
Upvotes: 7