Hello Aspose Community,
I’m currently working on a Java project where I need to convert DOCX files to PDF format using Aspose.Words for Java. However, I’ve encountered an issue and could use some assistance in resolving it.
Here’s a problem I’m facing:
- Error Message: When attempting to convert a DOCX file to PDF using the Aspose.Words for Java library, I’m receiving an error message stating: “Exception in thread ‘main’ java.lang.NoClassDefFoundError: com/aspose/words/Document.”
- Code Snippet: Below is the relevant portion of my Java code that’s responsible for the conversion:
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
public class DocxToPdfConverter {
public static void main(String[] args) {
String docxFilePath = "input.docx";
String pdfFilePath = "output.pdf";
// Load the DOCX document
Document doc = new Document(docxFilePath);
// Save the document in PDF format
doc.save(pdfFilePath, SaveFormat.PDF);
}
}
- Environment Details: I’m using Aspose.Words for Java version 21.10 and Java version 11.0.12 on a Windows 10 machine.
I’ve tried troubleshooting the issue by checking the classpath and ensuring that all necessary JAR files are included, but I’m still unable to resolve the error.
I also check this : https://forum.aspose.com/t/convert-docx-to-pdf-document-on-android-mobile-devices-using-aspose-words-for-android-via-javasalesforce But I have not found any solution.
Thank you in advance for your help!