APACHE ODF TOOLKIT (INCUBATING) 使用什么依赖项

What dependencies to use for APACHE ODF TOOLKIT (INCUBATING)

我正在尝试使用以下代码加载 .ods 文件:

import org.odftoolkit.simple.SpreadsheetDocument;
SpreadsheetDocument data = SpreadsheetDocument.loadDocument(f);

我添加了 import 语句以显示我正在使用哪个包。

但是我一直收到 java.lang.NoClassDefFoundError。我试过添加许多不同的库。目前我的 eclipse 构建路径中有这些库:libraries in my eclipse build path

我收到这个错误

Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/hpl/jena/rdf/model/RDFNode
    at org.odftoolkit.odfdom.pkg.OdfFileDom.initialize(OdfFileDom.java:215)
    at org.odftoolkit.odfdom.pkg.manifest.OdfManifestDom.initialize(OdfManifestDom.java:74)
    at org.odftoolkit.odfdom.pkg.OdfFileDom.<init>(OdfFileDom.java:132)
    at org.odftoolkit.odfdom.pkg.manifest.OdfManifestDom.<init>(OdfManifestDom.java:63)
    at org.odftoolkit.odfdom.pkg.OdfFileDom.newFileDom(OdfFileDom.java:189)
    at org.odftoolkit.odfdom.pkg.OdfPackage.parseManifest(OdfPackage.java:1187)
    at org.odftoolkit.odfdom.pkg.OdfPackage.readZip(OdfPackage.java:454)
    at org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:425)
    at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:256)
    at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:318)
    at org.odftoolkit.simple.Document.loadDocument(Document.java:319)
    at org.odftoolkit.simple.SpreadsheetDocument.loadDocument(SpreadsheetDocument.java:203)
    at FirstLoadComponent.main(FirstLoadComponent.java:11)
Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.rdf.model.RDFNode
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 13 more

任何关于如何获取我的代码的建议 运行 或任何替代我对 .ods 文件进行简单读写的建议都将非常受欢迎。

至少要加上commons-validator-1.5.0.jarjena-core-2.11.2.jarjena-iri-1.0.2.jar

可以通过 maven 命令 mvn dependency:tree.

获取完整的依赖项 jar
org.apache.odftoolkit:odfdom-java:jar:0.8.11-incubating
+- org.apache.odftoolkit:taglets:jar:0.8.11-incubating:compile
|  \- com.sun:tools:jar:1.7.0:system
+- xerces:xercesImpl:jar:2.9.1:compile
+- xml-apis:xml-apis:jar:1.3.04:compile
+- org.apache.jena:jena-core:jar:2.11.2:compile
|  +- org.slf4j:slf4j-api:jar:1.7.6:compile
|  +- org.apache.jena:jena-iri:jar:1.0.2:compile
|  +- org.slf4j:slf4j-log4j12:jar:1.7.6:compile
|  \- log4j:log4j:jar:1.2.17:compile
+- net.rootdev:java-rdfa:jar:0.4.2:compile
\- commons-validator:commons-validator:jar:1.5.0:compile
   +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
   +- commons-digester:commons-digester:jar:1.8.1:compile
   +- commons-logging:commons-logging:jar:1.2:compile
   \- commons-collections:commons-collections:jar:3.2.2:compile

如果你不想以后得到java.lang.NoClassDefFoundError, 您还应该添加这些罐子。它们可以在 odftoolkit-0.6.2-incubating-bin.zipodfvalidator-1.1.8-incubating.war 中找到.