I am evaluating aspose api and for converting ppt to pdf, i am using Aspose.slides. I am getting error while loading the presentation.
my code is as below
FileInputStream fstream = new FileInputStream(folder + “\sample.ppt”);
com.aspose.slides.LoadOptions opts = new com.aspose.slides.LoadOptions();
opts.setLoadFormat(com.aspose.slides.LoadFormat.Ppt);
Presentation pres = new Presentation(fstream ,opts);
Error
java.lang.NoClassDefFoundError: Could not initialize class com.aspose.slides.ln
at com.aspose.slides.o0.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Presentation.(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
ppt is sample ppt with just one slide with hello title.
I am using Jdk 11 and windows 10.
I am not able to upload ppt. I am attaching an image of the ppt. Its a simple ppt with one slide and Hello text written. Same error with any ppt/pptx i try to convert.
@JinuJoseph,
I made simple presentations in PPT and PPTX formats and tested your code example. I have found no errors. Please check your application code and look at this post and Jared’s answer.
I have inlcuded Aspose pdf, word and email in same way and its working fine. I have added aspose slides jar to classpath as well. Still getting the same error.
@JinuJoseph,
In your case, I would suggest you to make a simple empty project containing your code example only with Aspose.Slides dependency and check the problem more isolated.
I have created a simple maven project and included only aspose slides. I am getting below error.
Exception in thread “main” java.lang.ExceptionInInitializerError
at com.aspose.slides.internal.oq.public.this(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.ano.(Unknown Source)
at com.aspose.slides.ln.(Unknown Source)
at com.aspose.slides.o0.(Unknown Source)
at com.aspose.slides.Presentation.do(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at sample.SampleConverter.main(SampleConverter.java:13)
Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path.
com.aspose.slides.internal.fs.catch.if(Unknown Source)
com.aspose.slides.internal.on.double.(Unknown Source)
com.aspose.slides.internal.oq.public.this(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.ano.(Unknown Source)
com.aspose.slides.ln.(Unknown Source)
com.aspose.slides.o0.(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)
@JinuJoseph,
I checked your maven project and found no problems. ExceptionInInitializerError signals that an unexpected exception has occurred in a static initializer, but your code doesn’t have the static initializer.
Please check your code with my PPT sample sample.zip (22.0 KB), just in case.
I tried with the sample.ppt. I have same error. Cause of the error is Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path… This doesn’t seam like error due to missing jar or initializer. This is thrown from within aspose slides.jar.
@JinuJoseph,
Please check the next code example on your end and share the StackTrace string:
FileInputStream inputStream = new FileInputStream("<path to input PPT file>");
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.Ppt);
Presentation presentation = new Presentation(inputStream, loadOptions);
FileOutputStream outputStream = new FileOutputStream(new File("<path to output PDF file>"));
presentation.save(outputStream, SaveFormat.Pdf);
outputStream.close();
I have given the above code and executed. I am getting same error.
Exception in thread “main” java.lang.ExceptionInInitializerError
at com.aspose.slides.internal.oq.public.this(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.internal.oq.public.(Unknown Source)
at com.aspose.slides.ano.(Unknown Source)
at com.aspose.slides.ln.(Unknown Source)
at com.aspose.slides.o0.(Unknown Source)
at com.aspose.slides.Presentation.do(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at com.aspose.slides.Presentation.(Unknown Source)
at sample.SampleConverter.main(SampleConverter.java:21)
Caused by: class com.aspose.slides.exceptions.ArgumentException: Illegal characters in path.
com.aspose.slides.internal.fs.catch.if(Unknown Source)
com.aspose.slides.internal.on.double.(Unknown Source)
com.aspose.slides.internal.oq.public.this(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.internal.oq.public.(Unknown Source)
com.aspose.slides.ano.(Unknown Source)
com.aspose.slides.ln.(Unknown Source)
com.aspose.slides.o0.(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)
com.aspose.slides.Presentation.(Unknown Source)
sample.SampleConverter.main(SampleConverter.java:21)
at com.aspose.slides.internal.fs.catch.if(Unknown Source)
at com.aspose.slides.internal.on.double.(Unknown Source)
… 10 more Error.png (65.1 KB)
@JinuJoseph,
Please try the next solution. Click the right button on your Eclipse project and select Properties. Click the Resource tab and select UTF-8 for Text file encoding settings settings.png (21.1 KB)
.