0

I'm trying to use dcm4che (recent version 2.0.29) in a new DICOM project. I got the following error trying to convert a DICOM file into jpeg. I was unable to find the jar file containing the com.sun.medialib.codec.jpeg.Decoder class. Can anyone give me an idea where can I find it?

I installed jai 1.1.2.01 (lastest version found in oracle's download page) I probed it with java 6, 7 and 8.

Here my code:

    public static void main(String[] args) {
    try {

        //com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader
        //com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader

        ImageIO.scanForPlugins();
        IIORegistry reg = IIORegistry.getDefaultInstance();
        reg.registerApplicationClasspathSpis();

        CLibJPEGImageReaderSpi prov = new com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi();
        System.out.println("prov: "+prov.getClass().getName());
        System.out.println("prov: "+prov.getPluginClassName()+" ("+prov.getDescription(Locale.US)+")");
        for (String t:prov.getMIMETypes()){
            System.out.println("MIME: "+t);
        }
        reg.registerServiceProvider(prov, ImageReaderSpi.class);
        Dcm2Jpg dcm2jpg=new Dcm2Jpg();

        File origen=new File("c:/tmp/dicom/2.25.140624125599408099713879344899488955633.dcm");
        File destino=new File("c:/tmp/dicom/prueba.jpg");
        dcm2jpg.convert(origen, destino);

And here console output:

javax.imageio.IIOException: codecLib error
at com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader.getInfoImage(CLibJPEGImageReader.java:207)
at com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader.getImageTypes(CLibJPEGImageReader.java:274)
at javax.imageio.ImageReader.getRawImageType(ImageReader.java:665)
at com.sun.media.imageioimpl.plugins.clib.CLibImageReader.read(CLibImageReader.java:571)
at org.dcm4che2.imageioimpl.plugins.dcm.DicomImageReader.read(DicomImageReader.java:778)
at org.dcm4che2.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:175)
at es.cimkey.dicomclient.DicomClient.main(DicomClient.java:94)
Caused by: java.lang.NoClassDefFoundError: com/sun/medialib/codec/jpeg/Decoder
    at com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader.getInfoImage(CLibJPEGImageReader.java:199)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: com.sun.medialib.codec.jpeg.Decoder
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 7 more
MWiesner
  • 8,868
  • 11
  • 36
  • 70
wgualla
  • 61
  • 6
  • "Caused by: java.lang.NoClassDefFoundError: com/sun/medialib/codec/jpeg/Decoder " ? – Thorbjørn Ravn Andersen Aug 03 '15 at 17:10
  • Yes, textually copied from my std out. – wgualla Aug 04 '15 at 07:31
  • Which version of dcm4che are you using in your setup - please provide exact version of it. Which OS you are on btw? What is the result of "java -version" output. Please provide more information on that. – MWiesner Aug 04 '15 at 08:47
  • I'm using dcm4che 2.0.29 and the same result got with dcm4che 2.0.29, in windows 8.1 64bit and windows 2008 32bit. – wgualla Aug 04 '15 at 08:58
  • `java version "1.7.0_71" Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)` – wgualla Aug 04 '15 at 09:02
  • Have you tried with dcm4che 3.3.7? it's kind of a modernized version of dcm4che? maybe they fixed the dependency to the internal com.sun.medialib.XYZ classes? – MWiesner Aug 04 '15 at 09:51

1 Answers1

0

JAI does not work on 64-bit Windows Java. Try using the 32-bit JRE on your 64-bit Windows machine.

See also: JAI and ImageIO for 64 bit Windows

Community
  • 1
  • 1
cneller
  • 1,542
  • 1
  • 15
  • 24