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

devsda picture devsda · Aug 7, 2015 · Viewed 16.6k times · Source

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

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

Below is the resolution, I found on SO -

Set dynamic.classpath (property present in workspace.xml) to 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

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

Answer

Alexander Oh picture Alexander Oh · Feb 26, 2018

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.

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