简体   繁体   English

在JDK 4中使用apache poi 3.9的变通办法

[英]Workarounds for using apache poi 3.9 with JDK 4

This is a follow up question here . 这是一个后续的问题在这里 I just found this caption in Apache POI website . 我刚刚在Apache POI网站上找到了此标题。

POI 3.5 and later requires the JDK version 1.5 or later. POI 3.5和更高版本需要JDK 1.5或更高版本。 Versions prior to 3.5 require JDK 1.4+ 3.5之前的版本需要JDK 1.4+

Clearly, that's the reason I can't build my Java program. 显然,这就是我无法构建Java程序的原因。 I would just like to know if there are any workarounds where I can successfully build my project in Ant using my current settings. 我只想知道是否有任何变通办法可以使用当前设置在Ant中成功构建项目。

Settings 设定值

  • Apache POI - 3.9 Apache POI-3.9
  • JDK - 1.4.2 (4.0) JDK-1.4.2(4.0)

Any advice, tips, or hacks are welcome. 欢迎任何建议,技巧或技巧。 Thanks in advance! 提前致谢!

Java 1.4 is pretty old now - it was released in 2002 so over 10 years ago. Java 1.4现在已经很老了-它于2002年发布,距今已有10多年了。 Regular support ended in 2008, so I dread to think how much you're having to pay Oracle for extended support for it... If possible divert some of that cash to an upgrade project! 常规支持在2008年结束,因此我担心您需要向Oracle支付多少以获得扩展支持……如果可能,将其中的一部分现金用于升级项目!

The last version of Apache POI to run on Java 1.4 was POI 3.2, released in October 2008. Source and binary packages of it are available from the Apache dist archive . 在Java 1.4上运行的Apache POI的最新版本是POI 3.2,该版本于2008年10月发布。其源代码和二进制程序包可从Apache dist归档文件中获得 There are two main snags with using POI 3.2 today, the first is that it only supports the binary file formats. 今天,使用POI 3.2有两个主要障碍,第一个是它仅支持二进制文件格式。 It does not support the OOXML formats such as .xlsx, .pptx, .docx. 它不支持OOXML格式,例如.xlsx,.pptx,.docx。 Support for those (via XSLF, XSSF and XWPF) was only introduced with POI 3.5, and required the bump to Java 5 as the minimum. 仅通过POI 3.5引入了对这些功能(通过XSLF,XSSF和XWPF的支持)的支持,并且最低要求将对Java 5的要求提高。 The second issue is you'll be missing out on 5 years of bug fixes and new features , of which there have been a lot! 第二个问题是您将错过5年的错误修复和新功能 ,其中有很多!

It's been a few years since anyone asked about newer versions of Apache POI on old JDKs (everyone else has managed to upgrade to something with normal support available!). 自从有人问到有关旧JDK的Apache POI的较新版本已经过去了几年(其他人都设法升级到了可以使用常规支持的东西!)。 When people were asking, a common answer was to try Retroweaver , which should let you load and run JDK 5 code on JDK 1.4. 当人们问时,一个常见的答案是尝试Retroweaver ,它应该允许您在JDK 1.4上加载和运行JDK 5代码。 I've not tried it myself, but people given that answer seemed to be happy so I assume it'll do the trick... 我自己还没有尝试过,但是得到这个答案的人似乎很高兴,所以我认为它会成功的...

(Converting POI 3.9 to run on JDK 1.4 would be a lot of work for you. Since the 3.2 days, most of the new code has used generics, lots of old code has been greatly tidied up and simplified by moving to generics, I think there's the odd bit of varags, something about date formatters rings a bell, and there's all the XML stuff. It could be done, but it won't be quick) (将POI 3.9转换为在JDK 1.4上运行将是您很多工作。自3.2天以来,大多数新代码都使用了泛型,我认为通过转换成泛型可以大大整理和简化许多旧代码。有一些奇怪的变量,一些关于日期格式的事情响起了钟声,还有所有的XML东西。虽然可以做到,但是不会很快)

I guess this is very difficult. 我想这很难。 Just take an example=> suppose POI 3.9 is using feature of Generics or varargs of jdk 1.5 , then how could you compile it with jdk 1.4 . 仅举一个例子=>假设POI 3.9使用jdk 1.5Genericsvarargs功能,那么如何用jdk 1.4编译。 I suggest you either downgrade your POI version lower or upgrade your jdk version higher. 我建议您将POI版本降级或将jdk版本升级。

Edit: Add maven dependencies add support for POI 3.2 like below code 编辑:添加Maven依赖项添加对POI 3.2的支持,如下代码

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.2-FINAL</version>
</dependency>

I used Poi 3.8 migrated to jdk 1.4 . 我使用Poi 3.8迁移到jdk 1.4 It works :-) 有用 :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM