A full stack trace would probably be useful. However, if your description of the exception is accurate, it does not tell you that it cannot find the image file. He tells you that he cannot read it. Are you sure that the jpg file is not corrupted or for some other reason is not recognized as jpg for the ImageIO class?
The ImageIO.read () method throws an exception with a reason for entering == null if the resource is null. I think it finds it. It just can't read it as a jpg file (although it's hard to be sure without a full stack trace).
If your image resource is indeed at the top level of the jar file, then you do not need any leading file separator. Therefore, if your banner looks like this:
1523 Tue Mar 30 23:14:50 CDT 2010 org/apache/log4j/xml/SAXErrorHandler.class<br> 286 Tue Mar 30 23:14:50 CDT 2010 org/apache/log4j/xml/UnrecognizedElementHandler.class<br> 4109 Tue Mar 30 23:14:52 CDT 2010 org/apache/log4j/xml/XMLLayout.class<br> 745 Tue Mar 30 23:14:52 CDT 2010 org/apache/log4j/xml/XMLWatchdog.class<br> 7028 Tue Mar 30 23:14:34 CDT 2010 org/apache/log4j/xml/log4j.dtd<br> 911 Wed May 11 14:31:30 CDT 2011 redball.gif
You downloaded redball.gif with:
Image image = (ImageIO.read(this.getClass().getClassLoader().getResource("redball.gif")));
source share