Java 打开 zip 文件或 JAR 清单时出错:C:\Program

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23530157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 23:38:06  来源:igfitidea点击:

Error opening zip file or JAR manifest missing : C:\Program

javaeclipsegoogle-app-engineeclipse-wtp

提问by Michael Osofsky

I'm on step "Running project on the Server" from https://developers.google.com/appengine/docs/java/webtoolsplatform#dynamic_web_projectand I ran into a problem:

我正在从https://developers.google.com/appengine/docs/java/webtoolsplatform#dynamic_web_project执行“在服务器上运行项目”的步骤,但遇到了一个问题:

Error occurred during initialization of VM agent library failed to init: instrument Error opening zip file or JAR manifest missing : C:\Program

初始化 VM 代理库期间发生错误无法初始化:仪器打开 zip 文件或 JAR 清单时出错:C:\Program

Another person reported a similar problem here: Error opening zip file or JAR manifest missing : C:/Program. But the solution was for a different set of technologies. I'm using Eclipse, Web Tools Platform, and Google-App-Engine.

另一个人在这里报告了类似的问题:Error opening zip file or JAR manifest missing : C:/Program。但解决方案是针对一组不同的技术。我正在使用 Eclipse、Web 工具平台和 Google-App-Engine。

Most likely it's because my Java is installed in C:\Program Files, a directory which contains a space. But I'm not sure how to fix this. I'm not sure how to safely move the Java\jre7 directory to a directory without a space in it.

很可能是因为我的 Java 安装在 C:\Program Files 中,这是一个包含空格的目录。但我不知道如何解决这个问题。我不确定如何安全地将 Java\jre7 目录移动到一个没有空格的目录。

采纳答案by Michael Osofsky

Jordan Fish from Google Cloud Platform Support helped me solve this problem. He said:

来自 Google Cloud Platform Support 的 Jordan Fish 帮助我解决了这个问题。他说:

As far as the error message when you try to start the dev_appserver, I believe this is probably due to a vm argument in the run configuration for your project. Can you please go to the run configuration (with the project selected, go to the Run menu and select Run Configurations), click on the Arguments tab, and see what is listed in the VM arguments text box?

至于尝试启动 dev_appserver 时的错误消息,我相信这可能是由于项目的运行配置中的 vm 参数造成的。您能否转到运行配置(选择项目,转到运行菜单并选择运行配置),单击参数选项卡,然后查看 VM 参数文本框中列出的内容?

Here was my original VM arguments:

这是我的原始 VM 参数:

-javaagent:C:\Program Files\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.9.4\appengine-java-sdk-1.9.4\lib\agent\appengine-agent.jar -Xmx512m -Dappengine.fullscan.seconds=5 -Ddatastore.default_high_rep_job_policy_unapplied_job_pct=50

Here is what I changed it to (added double quotes around the directory that's passed as the -javaagent: param):

这是我将其更改为的内容(在作为 -javaagent: param 传递的目录周围添加双引号):

-javaagent:"C:\Program Files\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.9.4\appengine-java-sdk-1.9.4\lib\agent\appengine-agent.jar" -Xmx512m -Dappengine.fullscan.seconds=5 -Ddatastore.default_high_rep_job_policy_unapplied_job_pct=50

This fixed my problem, I was able to complete step "Running project on the Server" from https://developers.google.com/appengine/docs/java/webtoolsplatform#dynamic_web_project

这解决了我的问题,我能够从https://developers.google.com/appengine/docs/java/webtoolsplatform#dynamic_web_project完成步骤“在服务器上运行项目”

回答by Dozie

Run your cmd as an Admin. When you try to startup your server and you are not starting it up as an admin you get this error.

以管理员身份运行您的 cmd。当您尝试启动服务器但不是以管理员身份启动时,您会收到此错误。

回答by Jason D

If you use IntelliJ the solution appears to be slightly different. You need to edit the Run Configuration the same way that the Eclipse users do, but add the "VM Options" using this format instead:

如果您使用 IntelliJ,解决方案似乎略有不同。您需要以与 Eclipse 用户相同的方式编辑运行配置,但使用以下格式添加“VM 选项”:

-javaagent:[/absolute/path/DMEnhancerJava-1.0.jar][classes=META-INF/]

-javaagent:[/absolute/path/DMEnhancerJava-1.0.jar][classes=META-INF/]

Note the formatting with the brackets after the colon with no spaces for each parameter. If you miss that you'll get a runtime error message about JavaAgent expecting that input format.

注意冒号后的括号格式,每个参数没有空格。如果您错过了,您将收到一条关于 JavaAgent 需要该输入格式的运行时错误消息。

Also, remember that if you use a build tool like Maven or Gradle and add this to your JAVA_ARGS variable (via something like MAVEN_OPTS) you'll need to wrap the whole thing in double quotes.

另外,请记住,如果您使用像 Maven 或 Gradle 这样的构建工具并将其添加到您的 JAVA_ARGS 变量(通过类似 MAVEN_OPTS 的东西),您需要将整个内容用双引号括起来。

The second parameter appears to be necessary to tell DMEnhancer what to instrument (mine was relative to the top level of my classpath; because my compiled POJOs were in the META-INF directory).

第二个参数似乎是告诉 DMEnhancer 需要检测的参数(我的是相对于我的类路径的顶级;因为我编译的 POJO 位于 META-INF 目录中)。

Lastly, you may notice that you sometimes get an error talking about a class being implemented in two places in the classpath internal to the VM:

最后,您可能会注意到,有时会在谈论在 VM 内部类路径中的两个位置实现类时出错:

Class JavaLaunchHelper is implemented in both <Two full classspaths shown here> One of the two will be used. Which one is undefined.

This seems to happen because of a bug in the JVM and is fixed (on MacOS X) in 1.8u152 (at the time of writing, this is considered an Early Access Release available here). See this other answerfor more information on this JVM bug.

这似乎是由于 JVM 中的错误而发生的,并且在 1.8u152 中已修复(在 MacOS X 上)(在撰写本文时,这被视为此处提供的早期访问版本)。有关此JVM 错误的更多信息,请参阅此其他答案

回答by Crytis

You just have to add ""to your jar file behind -javaagent:

你只需要添加""到你的 jar 文件后面-javaagent

回答by Inzamam Syed

Export jar with manifest file in eclipse as follows:

在eclipse中用manifest文件导出jar如下:

enter image description hereOR

在此处输入图片说明或者

Merge manifest file with created jar. CMD: jar ufm /Users/inzamam/Desktop/inzaa.jar META-INF/MANIFEST.MF

将清单文件与创建的 jar 合并。CMD:jar ufm /Users/inzamam/Desktop/inzaa.jar META-INF/MANIFEST.MF