I have had this problem before, but it has been a while. Now it resurfaced: I am having an sbt-build based Scala project in IntelliJ IDEA, and when I launch a run config, the program does not find resources via getResource
or getResourceAsStream
. It did work before, so definitely the paths in my code are correct. For example, here is a view of the project browser:
You can see that the resources
directory is correctly marked, and so "/at/iem/sysson/color-tables.bin" should be found. Here is the reader code:
package at.iem.sysson
object Main {
lazy val colorTables: Map[String, ColorPaletteTable] = {
val is = Main.getClass.getResourceAsStream("color-tables.bin")
...
}
}
This used to work in IntelliJ, it still works when running through sbt
or creating a standalone application. But now with my run config from IntelliJ it is broken - getResourceAsStream
returns null
.
I have already deleted the .idea
project and recreated it from scratch. I have also quit and restarted IntelliJ. The resources are definitely marked:
What's wrong? It looks related to this, but deleting and recreating the run configuration does not help. I do get /usr/bin/java -Didea.launcher.port=7537 ...
, but the resources
directory is simply missing from the -classpath
.
The same has just happened to me (IntelliJ IDEA 2016.3.5).
When I looked into the target/scala-2.11/classes
dir, the resource dirs/files were missing.
Just rebuilding the project didn't help, but deleting target/scala-2.11/classes
and rebuilding did.