I’m running scala from the command line like this
scala -classpath dir/my.jar
dir/my.jar contains a file /my-resource.xml.
In the scala REPL, I do this
classOf[Object].getResourceAsStream(“/my-resource.xml”)
But I always get back null. Any idea why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re asking the wrong classloader. The classloader who loaded
java.lang.Objectis probably the boot classloader; he doesn’t have access to your classes.Try this: