本文介绍了使用apache poi 3.9的Java程序在XML构建文件中遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,在构建 xml 中遇到错误.从日志中,我认为错误与 apache poi 库poi-ooxml-3.9-20121203"有关,并且与 Java 版本有关.我目前使用的是 JDK 4 和 apache poi 3.9.

Hi encountered an error in build xml. From the log i think that the error is with apache poi library "poi-ooxml-3.9-20121203" and regarding Java versions.I am currently using JDK 4 and apache poi 3.9.

Buildfile: C:\POITest\build.xml
    init:
    clean:
       [delete] Deleting directory C:\POITest\build
       [delete] Deleting directory C:\POITest\dist
    init:
        [mkdir] Created dir: C:\POITest\dist
        [mkdir] Created dir: C:\POITest\build
        [mkdir] Created dir: C:\POITest\dist\lib
    compile:
        [javac] C:\POITest\build.xml:38: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
        [javac] Compiling 1 source file to C:\POITest\build
        [javac] C:\POITest\src\poi\test\TestMain.java:8: cannot access org.apache.poi.openxml4j.exceptions.InvalidFormatException
        [javac] bad class file: C:\POITest\lib\poi3-9\poi-ooxml-3.9-20121203.jar(org/apache/poi/openxml4j/exceptions/InvalidFormatException.class)
        [javac] class file has wrong version 49.0, should be 48.0
        [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
        [javac] import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
        [javac]                                            ^
        [javac] 1 error

POI 罐子列表

/POITest/lib/poi3-9/commons-codec-1.5.jar
/POITest/lib/poi3-9/commons-logging-1.1.jar
/POITest/lib/poi3-9/dom4j-1.6.1.jar
/POITest/lib/poi3-9/junit-3.8.1.jar
/POITest/lib/poi3-9/log4j-1.2.13.jar
/POITest/lib/poi3-9/poi-3.9-20121203.jar
/POITest/lib/poi3-9/poi-examples-3.9-20121203.jar
/POITest/lib/poi3-9/poi-excelant-3.9-20121203.jar
/POITest/lib/poi3-9/poi-ooxml-3.9-20121203.jar
/POITest/lib/poi3-9/poi-ooxml-schemas-3.9-20121203.jar
/POITest/lib/poi3-9/poi-scratchpad-3.9-20121203.jar
/POITest/lib/poi3-9/stax-api-1.0.1.jar
/POITest/lib/poi3-9/xmlbeans-2.3.0.jar

如果您需要查看构建文件,请告诉我.谁能告诉我我需要做什么来解决这个问题.谢谢

Just let me know if you need to see the build file.Can anyone tell me what I need to do to solve this. Thanks

推荐答案

49.0 和 48.0 是类文件格式的版本号.该错误消息表示 POI-3.9 已编译为 JDK 5 类文件格式,并且您尝试将其与 JDK 4 一起使用.当然,JDK 4 不支持 JDK 5 类文件格式.我认为您可以尝试使用旧版本的 POI.或者只使用 JDK 5.

49.0 and 48.0 are the version number of the class file format. The error message means that POI-3.9 was compiled to JDK 5 class file format and you tried to use it with JDK 4. Of course, JDK 4 couldn't support JDK 5 class file format. I think you can try older version POI. Or just use JDK 5.

1、从 POI 3.5 开始,需要 JDK 1.5.所以你可以使用 POI 3.4.请参考这篇文章:Apache POI JDK 版本.

1, From POI 3.5, it requires JDK 1.5. So you can use POI 3.4. Please refer to this post: Apache POI JDK version.

2、已经有人把POI 3.8迁移到JDK 1.4了.检查 Apache POI (3.8 final) 迁移到 JDK 1.4.谨慎使用非官方二进制文件.它可能无法完全测试.

2, Someone has already migrated POI 3.8 to JDK 1.4. Check Apache POI (3.8 final) migrated to JDK 1.4. Be caution to use non-offical binary. It might not test fully.

正在使用的类文件格式的主要版本号:

Major version number of the class file format being used:

  • J2SE 7 = 51(0x33 十六进制)
  • J2SE 6.0 = 50(0x32 十六进制)
  • J2SE 5.0 = 49(0x31 十六进制)
  • JDK 1.4 = 48(0x30 十六进制)
  • JDK 1.3 = 47(0x2F 十六进制)
  • JDK 1.2 = 46(0x2E 十六进制)
  • JDK 1.1 = 45(0x2D 十六进制)

参考:Java 类文件

这篇关于使用apache poi 3.9的Java程序在XML构建文件中遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 12:11