How to get getclass().getResource() from a static context?
The main method is a static method, so trying to access this
(= the current Object) will not work.You can replace that line by
URL keyFileURL = SecureFTP.class.getClassLoader().getResource("/home/xxxxx/.ssh/authorized_keys");
From: How to call getClass() from a static method in Java?
Just use TheClassName.class instead of getClass().
Old question but this hasn't been said yet. You can do this from a static context:
ClassLoader classLoader = ClassLoader.getSystemClassLoader();classLoader.getResource("filename");