3

I'm trying to read a word file .. but actually there is a problem it says that " The type org.apache.xmlbeans.XmlException cannot be resolved. It is indirectly referenced from required .class files " .. so can I know the problem ??

import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xwpf.usermodel.XWPFDocument;


public class Read_File {


    public static void main(String[] args) {
        try {
            FileInputStream fis = new FileInputStream("C:\\Users\\Desktop\\m.docx");
            org.apache.poi.xwpf.extractor.XWPFWordExtractor oleTextExtractor = new XWPFWordExtractor(new XWPFDocument(fis));
            System.out.print(oleTextExtractor.getText());            
        } catch (Exception e) {
                e.printStackTrace();
        }
    }

}
Mevo Hafez
  • 161
  • 1
  • 5
  • 10

2 Answers2

4

I've faced the same problem before.Adding the xmlbeans-2.3.0.jar can fix this problem.You can download the jar from here

Vignesh Vino
  • 1,242
  • 4
  • 25
  • 50
0

Make sure you have the JAR file that contains the XMLException in your classpath. You are probably running inside of Eclipse to get this message. It's saying that it's finding the class, but through some JAR file that's not in your classpath, which you are not allowed to do. There is probably a JAR file for XMLBeans.

Francis Upton IV
  • 19,322
  • 3
  • 53
  • 57