MyClass.class.getClassLoader().getResource(“”).getPath() throws NullPointerException
问题 I have code that is running correctly on a development machine but throws a NullPointerException when installed in a production environment. The line that throws the exception is the following: MyClass.class.getClassLoader().getResource("").getPath(); So I split this into multiple lines of code to see exactly which call was returning null, like this: ClassLoader cl = MyClass.class.getClassLoader(); URL url = cl.getResource(""); String path = url.getPath(); Now the url.getPath() call is