努力更新Maven和Eclipse中的JRE依赖关系 [英] Struggling to update JRE dependencies within Maven and Eclipse

查看:94
本文介绍了努力更新Maven和Eclipse中的JRE依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Eclipse中构建大型开源项目;它使用了Maven,所以我已经安装了各种插件(m2eclipse等),但是我对此设置有点陌生.

I'm trying to build a large Open Source project in Eclipse; it uses Maven so I've installed the various plugins (m2eclipse etc) but I'm a little unfamiliar with this setup.

我可以毫无问题地构建和运行我感兴趣的特定JAR.但是,当新建的JAR尝试打开大的ZIP文件时,我得到了:

I can build and run the particular JAR I'm interested in with no issues. However, when the newly built JAR tries to open a large ZIP file, I get this:

Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: invalid CEN header (bad sig
nature)
        at org.opentripplanner.graph_builder.impl.GtfsGraphBuilderImpl.buildGraph(GtfsGraphBuilderImpl.java:17
9)
        at org.opentripplanner.graph_builder.GraphBuilderTask.run(GraphBuilderTask.java:127)
        at org.opentripplanner.graph_builder.GraphBuilderMain.main(GraphBuilderMain.java:51)
Caused by: java.util.zip.ZipException: invalid CEN header (bad signature)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)

进行了一些研究表示此错误意味着java.util.ZipFile不能读取文件,因为它是ZIP64格式.显然,此问题已在Java 1.7中修复,因此,我忠实地更新了OS X上的JDK,并尝试通过在Eclipse中右键单击Maven项目来更改Maven项目,然后更改Project Facet,这反过来似乎已更新了Maven项目.该项目中的JRE库为1.7:

I did some research and it seems that this error means that java.util.ZipFile can't read the file because it's in ZIP64 format. Apparently this was fixed in Java 1.7, so dutifully I've updated the JDK on OS X, and tried to change the Maven project by right-clicking on it in Eclipse, then altering the Project Facet, which in turns seems to have updated the JRE libraries in that project to 1.7:

但是,这不起作用-即使重新构建了整个项目,我仍然会收到错误消息.

However, this doesn't work - I still get the error even having re-built the whole project.

旧的java.util.zip是否仍可能从某个地方拉入?我对Java中链接的工作方式不太熟悉,可以将旧的JDK像这样嵌入"到依赖项中吗?还是只是使用了目标机器上的java.util.zip? (绝对是JRE 1.7)我知道一个事实,引发异常的代码实际上包含在作为Maven依赖项引入的单独JAR中:

Is it possible that the old java.util.zip is still being pulled in from somewhere? I'm not too familiar with how linking works in Java, can older JDKs be 'embedded' like this within dependencies? Or does the java.util.zip just get used that's on the target machine? (this is definitely JRE 1.7) I know for a fact that the code throwing the exception is actually contained within a separate JAR that's pulled in as a Maven dependency:

我是否需要跟踪并针对Java 1.7重建此外部JAR,这是问题所在吗?还是有一个Maven父项目"的概念将我的新JRE 1.7回归到1.6?很抱歉,这些问题是否幼稚.

Do I need to track down and re-build this external JAR against Java 1.7, is that the issue here? Or is there a concept of a Maven 'parent project' that's regressing my new JRE 1.7 back to 1.6? Sorry if these questions are naive.

我本来以为它就像在运行时机器上更新JRE一样简单,但显然不是.那我该如何解决这个错误呢?

I originally thought that it would be as simple as just updated the JRE on the runtime machine, but apparently not. So how do I resolve this error?

推荐答案

假定问题确实是由使用较旧版本的Java引起的,则重建不会产生任何影响. 真正的问题是您的应用程序JAR在较旧的JRE上正在运行.

Assuming that the problem is really caused by using an older version of Java, then rebuilding is not going to make any difference. The real problem is that your application JAR is running on an older JRE.

在用于运行应用程序的命令外壳中,运行java -version.这将告诉您在随后运行java -jar yourApp.jar ...

In the command shell you are using to run your application, run java -version. That will tell you what JDK / JRE will be used when you then run java -jar yourApp.jar ...

这篇关于努力更新Maven和Eclipse中的JRE依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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