Seems like an exact duplicate of this question: How do I access a config file inside the jar?
Further to your problem with NullPointerException
, I suggest not to make sure it doesn't happen, but rather prepare for it and handle it properly. I'd go even further to ask you to always check your variables for null value, it's a good thing to do.