I have a .jp2
image file that I want to convert to .jpg
.
BufferedImage background = ImageIO.read(new File("images\\"
+ randNum + ".jp2"));
ImageIO.write(background, "jpg", new File("images\\" + randNum
+ ".jpg"));
I have got this exception :
java.util.ServiceConfigurationError: javax.imageio.spi.ImageWriterSpi: Provider com.github.jaiimageio.jpeg2000.impl.J2KImageWriterSpi could not be instantiated
...
Caused by: java.lang.NoClassDefFoundError: com/github/jaiimageio/impl/common/PackageUtil
...
Caused by: java.lang.ClassNotFoundException: com.github.jaiimageio.impl.common.PackageUtil
Apparently, a conflict occured, I was using classes from different libraries, here I had both jai_imageio
and jai-imageio-jpeg2000
, I solved this problem by simply removing one of them.