JAI : how to solve vendorName == null exception

July 22nd, 2009 by ThierryWasyl Leave a reply »

Hello everybody,

Have You ever used JAI (Java Advanced Imaging) ? If You used the class ImageIO in order to read and save images, the answer is yes.
Most of the time, You should not have problem when You deploy Your application with an executable JAR even if You’re using JAI. But, most of the time doesn’t mean never, so that’s a problem !
Recently I had to deploy an application as a JAR, and this application was using quantity of external library. And of course it used JAI.
Well, doing a JAR is not really a problem but …

In my case, the application was developped with Eclipse, and was running fine in it. But, when it comes to run it with a JAR, that was problematic…
I got an exception when a tried to load images, especially TIFF images. This exception was thrown by JAI and told me that the vendorName was null. Interessting : but which vendor ??

The answer is quiet simple : JAI needs sometimes to know the name of the vendor who developped the application, and the implementation of it… OK, you’ll tell me “Fine. It seems it’s my application, so I’m the vendor. But how do I specify that?”. And that’s the point.

When You deploy an application as an executable JAR, You probably know that You need a manifest file. And that manifest file is the key. A complete valid manifest file could be this :

Manifest-Version: 1.0
Main-Class: fr.free.thierrywasyl.myproject.launcher.Launch

But where did I specify the author? No where. But JAI will maybe need to know that, or You’ll get an exception about the vendor. So let’s add some lines, which are good to add (take it as a good practice) which are general:

Manifest-Version: 1.0
Implementation-Vendor: Sun Microsystems, Inc
Implementation-Title: Java Runtime Environment
Implementation-Version: 1.6.0
Main-Class: fr.free.thierrywasyl.myproject.launcher.Launch

So far so good. So are You a null vendor? Of course not, You get over the exception ;)
Enjoy and take care.

Advertisement

6 comments

  1. Eduardo says:

    Thank’s for your post!. It was drive me crazy

  2. ThierryWasyl says:

    You are welcome. Happy this tips is useful for somebody.

  3. work at home says:

    Very good work, interesting post, bookmarked !

  4. bitkidoku says:

    thanks you saved my day :)

  5. Andy says:

    How do you deploy a Java application that uses JIA?

    Am I right thinking the libraries are platform specific executables?

    Or am I completely wrong (again)?

  6. ThierryWasyl says:

    Deploying a Java application which uses JIA should not be a problem because JIA is installed with Java.
    But yes You’re right : JIA is kind of platform specific.
    You just have to take to some parameters, like this one :)

Leave a Reply