Fixing Swing applications created with Maven Uberjar plug-in Maven Uberjar Plugin
Friday, September 30, 2005 at 10:36 PM
Update: Instead of fixing the Uberjar plugin, using the faster JavaApp plugin may be a feasible alternative.
I had some troubles getting the Maven 1 Uberjar plugin to work with a Swing application:
URL url = Main.class.getClassLoader().getResource("icons/22/exit.png");
ImageIcon icon = new ImageIcon(url);
The application would hang on startup when the first ImageIcon was loaded from a URL and throw a NullPointerExceptio
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:115)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:251)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:217)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:185)
Apparently the URLImageSource class expects url.getHost() != null which is not the case and leads to the exception.
In order to fix the problem, get the classworlds 1.0 source release, apply this patch and run maven jar:install.
Next you need to update the maven uberjar plugin. Checkout the plugin from the maven cvs, apply this patch
|