Can't add resources in jar generated by scalac

22 views Asked by At

I have file in with an SQL query, which I need to run using SparkSQL. Since the file is too big, I don't want to copy it straight into the code.

.
├──_main.scala 
├──_resources 
│  └── query.sql

Howewer when I compile it

scalac -cp "<path-to-resources>/*:<jars path>/*" -d "main.jar" main.scala

and try to run, it throws NullPointerException when I try to call "mkString"

val queryIt = scala.io.Source.fromInputStream(getClass.getClassLoader.getResourceAsStream("query.sql"))
val query = try queryIt.mkString finally queryIt.close()

Error message

0

There are 0 answers