Niccko
Niccko

Reputation: 7

Can't add resources in jar generated by scalac

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

Upvotes: 0

Views: 22

Answers (0)

Related Questions