You need an actual object for this, because it's not a static method. Instead of
Class.getClassLoader()
use
(new
Test()).getClass().getClassLoader()
For your purposes (where you are not using any classloaders of your own) it's probably equivalent to use
ClassLoader.getSystemClassLoader()
if you want to avoid the creation of a Test object.