I need to pass the root "something" to a piece of code working with resources. I know that this "something" can't be a file, since this doesn't work in a JAR. So I'm passing an URL.
Before I started with OneJar I transformed an URL like
file:/some/path!/foo/bar/MyUrlSupplier.class
into
file:/some/path!/foo/images/
and used this as the root URL. With OneJar I'm getting
onejar:foo.bar.MyUrlSupplier.class
and transforming it into
onejar:foo.images
but whatever I do with this URL, nothing works. The best I get is this stacktrace caused by loading new ImageIcon(url)
:
Uncaught error fetching image:
java.lang.ClassCastException: sun.misc.Launcher$AppClassLoader cannot be cast to com.simontuffs.onejar.JarClassLoader
at com.simontuffs.onejar.JarClassLoader.getByteStream(JarClassLoader.java:753)
at com.simontuffs.onejar.Handler$1.getInputStream(Handler.java:50)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:126)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)