java 无法运行程序,错误=7,参数列表太长

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31876974/
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-11-02 19:17:28  来源:igfitidea点击:

Cannot run program, error=7, Argument list too long

javaintellij-ideajvmjava-8intellij-14

提问by devsda

I faced error while running unit test in intellij. Below is error message.

我在 intellij 中运行单元测试时遇到错误。下面是错误信息。

Error

错误

Error running CLASS_NAME.TEST_METHOD_NAME: Cannot run program "JAVA_PATH/bin/java" (in directory "WORKSPACE_PATH"): error=7, Argument list too long

运行 CLASS_NAME.TEST_METHOD_NAME 时出错:无法运行程序“JAVA_PATH/bin/java”(在目录“WORKSPACE_PATH”中):错误=7,参数列表太长

Below is the resolution, I found on SO -

以下是我在 SO 上找到的分辨率 -

Set dynamic.classpath(property present in workspace.xml) to true.

dynamic.classpath(workspace.xml 中存在的属性)设置为true.

Negative-effects -

负面影响 -

But because of above resolution, other unit tests are failing now.

但是由于上述分辨率,其他单元测试现在都失败了。

Reason - it is not loading other dependent module classpaths.

原因 - 它没有加载其他依赖模块类路径。

These are the links related to this problem - link1, link2

这些是与此问题相关的链接 - link1, link2

If anyone have any solution/workaround for this, please help me.

如果有人对此有任何解决方案/解决方法,请帮助我。

回答by Alex

https://blog.jetbrains.com/idea/2017/10/intellij-idea-2017-3-eap-configurable-command-line-shortener-and-more/

https://blog.jetbrains.com/idea/2017/10/intellij-idea-2017-3-eap-configurable-command-line-shortener-and-more/

looks like in modern variants of intellij you can select to put your path into a file or similar, this prevents expansion of your path to insane length.

看起来在 intellij 的现代变体中,您可以选择将路径放入文件或类似文件中,这可以防止将路径扩展到疯狂长度。

Thus changing the "shorten command line" parameter to JAR Manifest should fix the issue.

因此,将“缩短命令行”参数更改为 JAR 清单应该可以解决问题。