saurabh
saurabh

Reputation: 11

Reading DOCX file content

 try {
     Pattern p =  Pattern.compile(b.toUpperCase());
     POITextExtractor text = ExtractorFactory.createExtractor(file);                        
     String text1 = text.getText();
     Matcher m = p.matcher(text1.toUpperCase());
} 
catch(IOException | OpenXML4JException | XmlException e){} 

while running this code in NetBeans IDE 8.0 i am getting an error,

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/hwpf/OldWordFileFormatException

How to avoid this error. package included is poi.ooxml

Upvotes: 1

Views: 827

Answers (2)

Jileni Bouguima
Jileni Bouguima

Reputation: 444

you should add poi-scratchpad.jar to your build path or add this dependency to your pom.xml if maven project :

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-scratchpad</artifactId>
    <version>3.11</version>
</dependency>

you should use poi-scratchpad with version 3.7 or newer one.

Upvotes: 1

JamesB
JamesB

Reputation: 7894

You need to add the poi-scratchpad jar to your classpath. It contains the missing class: org.apache.poi.hwpf.OldWordFileFormatException.java.

Upvotes: 1

Related Questions