java中读取Doc或Docx文件的问题 [英] the problems with read Doc or Docx file in java

查看:50
本文介绍了java中读取Doc或Docx文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用 Java 读取 .doc.docx 文件时遇到了这个问题:

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.

推荐答案

好吧,听起来您还没有将相关的 Apache POI jar 文件放入您在执行时使用的类路径中.没有更多信息,我们只能说这些.

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.

  • 找出需要哪些 jar 文件
  • 找出是什么控制了您的类路径(这取决于您正在运行的应用程序类型)
  • 确保所有 jar 文件就位
  • 重新运行
  • 利润:)

例如,从命令行,在 Windows 上,您可能想要运行:

For example, from the command line, on Windows, you might want to run:

java -cp .;poi-whatever.jar foo.bar.Test

(适当地替换 jar 文件名和您的入口点名称.)

(Replace the jar file name and your entry point name appropriately.)

这篇关于java中读取Doc或Docx文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆