Question

In jar jai_imageio.jar there is class:

com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader

So i add jai_imageio.jar (and jai_core.jar, jai_codec.jar) to classpath. But this class seems not to be accessable for ImageIO. So this code:

ImageIO.scanForPlugins();
IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();
Iterator<ImageReader> ir = ImageIO.getImageReadersByFormatName("jpeg");
while(ir.hasNext()) {
    ImageReader r = ir.next();
    System.out.println("can read raster: " + r.canReadRaster());
    System.out.println(r);
}

results the following output:

can read raster: true
com.sun.imageio.plugins.jpeg.JPEGImageReader@54520eb

on 99% of machines. But on one machine it results this output:

Can read raster: false
com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader@163e9a1
Can read raster: true
com.sun.imageio.plugins.jpeg.JPEGImageReader@10cecb2

Why does it happens? Should i do more as just put the jar with ImageIO plugins on classpath? Can i somehow unload an ImageReader from ImageIO-Registry?

Background

Actually my problem is that some external unchangeable code is supposed to use the first ImageReader from ImageIO Registry to read the raster. But unfortunately on one PC the first ImageReader is CLibJPEGImageReader. The JDK and classpath are identical, so CLibJPEGImageReader should be always in registry, if put a jar with plugin on classpath is enough to make it visible for ImageIO.

Was it helpful?

Solution

The most likely reason is that the machine you're using CLibJPEGImageReader on has the JAI ImageIO library installed (http://java.net/projects/jai-imageio).

Why the others don't work (apart from the obvious) is because you've installed the 32-bit version of the libraries on a 64-bit system and not installed the multilib libraries (https://wiki.archlinux.org/index.php/Arch64_FAQ).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top