Bioformats in Matlab - JAI Error

I am running into an issue with bioformats in MATLAB and keep getting the following message:

“Error using bfGetReader (line 85)
Java exception occurred:
loci.formats.MissingLibraryException: Java Advanced Imaging (JAI) is required to read some TIFF files. Please install JAI from

I found on the Bioformats for MATLAB website:
" Troubleshooting

If you encounter an error trying to open JPEG-2000 data in MATLAB but the file will open e.g. in Fiji using Bio-Formats, it may be due to conflicting versions of JAI ImageIO in different JARs. As discussed on the component page, JAI ImageIO is no longer maintained and you will likely need to remove the conflicting JAR(s) as a workaround."

I am not clear on how to proceed. Does anyone have any advice?

Thank you!

This sounds like it is likely due to conflicting versions of JAI. If you run the below command does that give you the location of a JAR?


Hi David,

Thanks so much for your help. I abandoned this here but now have a new Mac and am still unable to open w MATLAB. The error is different, but the file type is the same. Do you have any suggestions? I am trying to open a Metamorph TIF using bioformats. Previously w Nikon ND2 files, it has been very simple to import!

I just tested out:
IM = ’ file address’
exist IM
Error using bfGetReader (line 85)
Java exception occurred:
java.lang.IndexOutOfBoundsException: Index: 8, Size: 1
at java.util.ArrayList.rangeCheck(
at java.util.ArrayList.get(
at ome.xml.model.Instrument.getLightSource(
at ome.xml.meta.OMEXMLMetadataImpl.setLaserID(
at ome.xml.meta.FilterMetadata.setLaserID(
at loci.formats.FormatReader.setId(
at loci.formats.ImageReader.setId(
at loci.formats.ReaderWrapper.setId(
at loci.formats.ChannelFiller.setId(
at loci.formats.ReaderWrapper.setId(
at loci.formats.ChannelSeparator.setId(

Error in bfopen (line 114)
r = bfGetReader(id, stitchFiles);

Thank you for any hep!

That error looks more like a bug for that particular dataset or format. If you have a sample file showing the exception which we could test you can upload it to

Hi, I’m having the same JAI error as the OP with no clear indicator of where to proceed.
Running the code you provided just leads to my bioformats package path:

As a note, I’m trying to read in a .ndpi Whole Slide Image.

Is the path that returns for your bioformats_package the correct path or is it the path to an older version?