ServiceConfigurationError

ServiceConfigurationError

本文介绍了java.util.ServiceConfigurationError:无法实例化提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .jp2 图像文件,我想将其转换为 .jpg.

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"));

我有这个例外:

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

推荐答案

显然发生了冲突,我使用的是来自不同库的类,这里我有 jai_imageiojai-imageio-jpeg2000,我通过简单地删除其中一个来解决这个问题.

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.

这篇关于java.util.ServiceConfigurationError:无法实例化提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 00:19