Trying to add "import" statement to my new scala project (I'm us开发者_运维百科ing IntelliJ 10.5.2 right now) syntax highlighter tells me that he cannot find java package:
import java.util.zip //Cannot resolve symbol java
object Main extends App {
override def main(args: Array[String]) {
}
}
What's wrong. What should I do to import this package?
Make sure that you have a Java SDK configured under:
File -> Project Structure -> Project -> Project SDK
See Where do I configure project JDK
File -> Project Structure -> Platform Settings -> SDKs -> change your JDK home path to the correct location of your latest JDK version.
In my case, the path was set as /usr/lib/jvm/java-1.11.0-openjdk-amd64
, so I changed it to /usr/lib/jvm/java-11-openjdk-amd64
and all my imports suddenly went from red to white, and there were no more error warnings in my scala project due to unknown java classes/methods.
OBS: The errors shown by IntelliJ were purely graphical, since I could build my project. But when I built them, my red imports would be removed by the ide. After this fix the problems desapeared.
My IntelliJ configuration:
IntelliJ IDEA 2019.3.2 (Community Edition)
Build #IC-193.6015.39, built on January 21, 2020
Runtime version: 11.0.5+10-b520.30 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-74-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1998M
Cores: 6
Registry:
Non-Bundled Plugins: org.intellij.scala
精彩评论