I'm trying to get load an image from my jar. But no matter what string I supply for getResource() it always returns null.
try {
System.out.println(Bootstrapper.class.getResource("./img/logo.png").toURI().getPath());
} catch (URISyntaxException ex) {
Logger.getLogger(CrawlerFrame.class.getName()).log(Level.SEVERE, null, ex);
}
ImageIcon ii = new ImageIcon(Bootstrapper.class.getResource("./img/logo.png"));
setIconImage(ii.getImage());
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at net.sharpcode.crawler.ui.CrawlerFrame.init(CrawlerFrame.java:35) at net.sharpcode.crawler.ui.CrawlerFrame.(CrawlerFrame.java:28) at net.sharpcode.crawler.Bootstrapper$1.run(Bootstrapper.java:55)
I've tried:
getResource("")
getResource(".")
getResource("./")
getResource("/img/logo.png")
Bootstrapper.class.getProtectionDomain().getCodeSource().getLocation().getPath()