Skip to main content

Latest version, test for in classpath

8 replies [Last post]
davidthi808
Offline
Joined: 2005-11-03

Hi;

A couple of questions. First of we use JAI_IIO and are very happy with it.

1. Is installing JAI_IIO still the best way to read/write bitmaps, or is this now incorporated into the root Java runtime now?

2. The compiler gives us a warning on using PNGMetadata, should we use something else? We use it to set the DPI when creating an IIOImage.

3. We test to see if JAI_IIO is installed by calling Class.forName("com.sun.media.imageio.stream.RawImageInputStream") and see if it throws an exception. Is this still the recomended way to check?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tomgroup
Offline
Joined: 2010-09-05

Hi,

I will try to answer some of your questions.

1) First, what do you mean by "root Java runtime"? Do you refer to the Java Development Kit? In that case, there is definitely some standard support for reading and writing image bitmap files in the JDK. This is apparent from the learning trial on Java2D (http://download.oracle.com/javase/tutorial/2d/images/loadimage.html). As I see it, jai-imageio adds support for some formats that are not supported by the JDK (like jpeg 2000). PNG and standard JPEG are already supported by the JDK.
You can let users of your software install the jai-imageio runtime libraries separately. My guess is that the license will also allow you to distribute these jar files with your application, provided that some license files are included.

3) You can also just query the available ImageReaders (for specific formats). Suppose you need PNG input and want to verify if the Java system has support for this. You can type:

Iterator readerIter = ImageIO.getImageReadersByFormatName("png");

while(readerIter.hasNext) {
ImageReader reader = readerIter.next(); // ok, use this reader to read png files
}

When the jai-imageio.jar is on your classpath, more formats should be supported besides PNG.

Hope this helps.

Tom

davidthi808
Offline
Joined: 2005-11-03

Hi;

Thanks for your post. To follow-up

1) At one time the plan was to merge IIO into the JDK. I was asking if that had been done yet. And if so, which version.

3) Many of our customers want to know if they have installed IIO correctly. So we need to have a means of seeing if it is in the classpath. We could query for a bitmap format that is not supported in the JDK as you suggest, but if a later JDK adds support for that format then that test will no longer be accurate.

??? - thanks - dave

tomgroup
Offline
Joined: 2010-09-05

Hi,

1) Ok, I understand now. As far as I know JDK 1.6 does not have the jai-imageio support.

3) I think that if a later JDK might add support for new formats the test will remain valid. The test basically just checks if the format you need is supported in any way (maybe by the JDK, or maybe by some other added libraries on your classpath). If there are multiple classes that understand the format you need, more ImageReaders will be returned by the test and you can choose any one you like from these. Now, if the JDK adds support for some hypothetical format X in the future the test that queries support for X is still valid and might even have a higher chance to succeed. If customers have some old java runtime without support for format X you can always supply some libraries such as jai-imageio to fill in that gap. You can supply jai-imageio in any case. That won't really hurt if X actually was supported on some platforms. You only end up with more ImageReaders. When you know for certain that every java runtime that is at least a couple of years old will have standard support for X you can just drop the extra libraries that you deliver with your application.

Regards,
Tom

Bob Deen

Careful, there are two different but closely related things here.

Image I/O itself is part of the core JDK, since at least 1.5 if not 1.4.
That's the infrastructure, and a number of format plugins. The
completely separate package JAI IIO Tools is not part of the core, and
probably won't be. That consists of more plugins, as well as the
imageread and imagewrite JAI operators,

Tom's on the right track with #3. If the format you need is supported,
it really shouldn't matter who's supporting it. However, if you really
need to know for sure (like, there's some exotic option not normally
supported), you should be able to query the provider metadata associated
with the plugin, make sure it matches what you expect.

HTH...

-Bob

On 9/5/10 9:03 AM, jai-imageio@javadesktop.org wrote:
> Hi,
>
> 1) Ok, I understand now. As far as I know JDK 1.6 does not have the jai-imageio support.
>
> 3) I think that if a later JDK might add support for new formats the test will remain valid. The test basically just checks if the format you need is supported in any way (maybe by the JDK, or maybe by some other added libraries on your classpath). If there are multiple classes that understand the format you need, more ImageReaders will be returned by the test and you can choose any one you like from these. Now, if the JDK adds support for some hypothetical format X in the future the test that queries support for X is still valid and might even have a higher chance to succeed. If customers have some old java runtime without support for format X you can always supply some libraries such as jai-imageio to fill in that gap. You can supply jai-imageio in any case. That won't really hurt if X actually was supported on some platforms. You only end up with more ImageReaders. When you know for certain that every java runtime that is at least a couple of years old will have standard
support for X you can just drop the extra libraries that you deliver with your application.
>
> Regards,
> Tom
> [Message sent by forum member 'tomgroup']
>
> http://forums.java.net/jive/thread.jspa?messageID=481921
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

davidthi808
Offline
Joined: 2005-11-03

On item (3), it's not a specific plugin we need. Our program supports any format that Java can render so we need to be able to answer the generic question of - did JAI get properly installed and is it in the classpath.

What's the best way to verify that?

thanks - dave

chcornwell
Offline
Joined: 2004-09-16

Somewhat of a hack, and it doesn't get you the version, but how about using Class.forName("com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet
") or some other class known to be unique to jai-imageiotools? If the library is not on the classpath this will throw a ClassNotFound exception, otherwise it should succeed.

- cc

davidthi808
Offline
Joined: 2005-11-03

Hi;

That's what we're doing. My concern with this approach is what if we use a class that gets moved to the JDK - is there any class that the IIO group says will be the last thing moved to the JDK?

thanks - dave

davidthi808
Offline
Joined: 2005-11-03

asking again - thanks - dave