问题
I am having this problem with reading a .doc
or .docx
file in Java:
java.lang.NoClassDefFoundError: org/apache/poi/hwpf/HWPFDocument
I don't understand why this is happening and would appreciate any help getting rid of this error.
回答1:
Well, that sounds like you haven't put the relevant Apache POI jar file(s) into the classpath you're using at execution time. Without more information, that's about all we can say.
- Find out which jar files are required
- Find out what's controlling your classpath (which will depend on what kind of app you're running)
- Make sure all the jar files are in place
- Rerun
- Profit :)
For example, from the command line, on Windows, you might want to run:
java -cp .;poi-whatever.jar foo.bar.Test
(Replace the jar file name and your entry point name appropriately.)
来源:https://stackoverflow.com/questions/12499372/the-problems-with-read-doc-or-docx-file-in-java