0

I'm trying to load the content of a Word document (Word 2007 with file extension .docx) into a JTextArea (txtLoadedText). I'm using a JFileChooser to select the Word document but when I select the document I get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/openxmlformats/schemas/wordprocessingml/x2006/main/DocumentDocument$Factory

I tried looking at this Stackoverflow question (How to avoid java.lang.NoClassDefFoundError), but it didn't make any difference.

How can I correct this?

The code I'm using is as follows:

JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
XWPFDocument doc = new XWPFDocument(new FileInputStream(chooser.getSelectedFile()));
XWPFWordExtractor extract = new XWPFWordExtractor(doc);
txtLoadedText.setText(extract.getText()); 

The jar files I have in place are:

poi-ooxml-3.8jar
xmlbeans.jar
poi-scratchpad-3.9.jar
poi-3.9.jar
dom4j.jar
poi-ooxml-3.7-20101029.jar
stax-api-1.0.1.jar
xbean.jar
Community
  • 1
  • 1
Osiris93
  • 296
  • 2
  • 18

1 Answers1

2

try add poi-ooxml-schemas.jar to your projekt

Piotr Rogowski
  • 3,642
  • 19
  • 24