We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

java.lang.NoClassDefFoundError: com/aspose/pdf/Document

Hi All,

I am new to java and aspose and I am trying to get below code working. But I get noclassdeffounderror. Can someone please help?

import com.aspose.pdf.*;

public class Main
public static void main(String[] args) throws Exception
System.out.println(“Hello World!”);
//open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“input.pdf”);
//get particular page com.aspose.pdf.Page pdfPage = pdfDocument.getPages().get_Item(1);
//create text fragment com.aspose.pdf.TextFragment textFragment = new com.aspose.pdf.TextFragment(“main text”);
textFragment.setPosition(new com.aspose.pdf.Position(100, 600));
//set text properties
// create TextBuilder object
com.aspose.pdf.TextBuilder textBuilder = new com.aspose.pdf.TextBuilder(pdfPage);
// append the text fragment to the PDF page textBuilder.appendText(textFragment);
// save updated PDF file pdfDocument.save(“Text_Added.pdf”);

I then run below on my server
javac -classpath aspose.pdf-11.4.0.jar Main.java
java Main
Exception in thread “main” java.lang.NoClassDefFoundError: com/aspose/pdf/Document
at com.company.Main.main(Main.java:14)
Caused by: java.lang.ClassNotFoundException: com.aspose.pdf.Document
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

Hi there,

Thanks for your inquriy. After initial investigation, we have logged a ticket PDFNEWJAVA-35807 in our issue tracking system for further investigation and rectification. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Hi there,

Thanks for your patience. Please note starting some code you need to add all the necessary dependencies into classpath. Depending on the system the command would look like this.

java -classpath aspose.pdf-11.4.0.jar; Main<o:p></o:p>


java -classpath aspose.pdf-11.4.0.jar: Main

Please feel free to contact us for any further assistance.

Best Regards,