Free Support Forum - aspose.com

About PdfConverter : PageToImage

Hi All,
Once I run the PageToImage.java program which relates with converting the .pdf to .jpg image I get following error.

Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/media/jai/codec/SeekableStream
at com.aspose.pdf.kit.at.bp(Unknown Source)
at com.aspose.pdf.kit.b9.a(Unknown Source)
at com.aspose.pdf.kit.n5.if(Unknown Source)
at com.aspose.pdf.kit.n5.a(Unknown Source)
at com.aspose.pdf.kit.b9.a(Unknown Source)
at com.aspose.pdf.kit.sw.fE(Unknown Source)
at com.aspose.pdf.kit.PdfConverter.doConvert(Unknown Source)
at aspose.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: com.sun.media.jai.codec.SeekableStream
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
… 8 more

I am using the aspose.pdf.kit.jar API. If any one knows the reasoin please give the answer.
Thanks in Advance.




Hi Omkar,

In order to convert the PDF files to images using Aspose.Pdf.Kit for Java, you also need Java Advanced Imaging (JAI). You can download it form this link. You need to set jai_codec.jar and jai_core.jar in class path as well.

I hope this helps. If you need any further assistance, please do let us know.
Regards,


Hi Latif,

Thank you for previous suggestion. As per your suggestion I am including the files jai_core.jar and jai_codec-1.1.3.jar still I get following error.

Exception in thread “main” java.lang.NoClassDefFoundError: javax/media/jai/OperationRegistrySpi
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)


I have question about Jars because both does not consist OperationRegistrySpi.java class. And my example is,

// Code :
static String path = “E:\slide/”;
try {
PdfConverter converter = new PdfConverter();
converter.bindPdf(path + “TS-4928.pdf”);

converter.doConvert(); // Problem Starts here !!

String prefix = path;
String suffix = “.jpg”;
int imageCount = 1;
while(converter.hasNextImage())
{
converter.getNextImage(prefix + imageCount + suffix, ImageType.JPEG);
imageCount++;
}

}
catch (java.io.IOException ioe)
{
System.out.println(ioe.getMessage() + ioe.getStackTrace());
}

I am using the Netbean 6.7.1 for that as a IDE.

Regards,
Omkar.

Hi Omkar,

You can find OperationRegistrySpi.class file under javax/media/jai in jai_core.jar. It looks like either you don’t have the right JAI package or the classpath to the jar files are not properly set. Can you please try to set the classpath properly to these two jar files and test run your application? If you still find any issues, please do let us know.

We’re sorry for the inconvenience.
Regards,