29

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.

Community
  • 1
  • 1
devsda
  • 4,112
  • 9
  • 50
  • 87
  • 1
    Anyone, please help. – devsda Sep 08 '15 at 13:28
  • Previously, I was working on RHEL OS, there I faced this issue. Now, I setup whole my code base on Ubuntu machine. Its working fine now. May be, its because of some of OS specific reason, may be it has bigger file to store classpaths. Whatever it is, its working fine for me. :) – devsda Nov 27 '15 at 04:42
  • Refer to the accepted answer for this question http://stackoverflow.com/questions/14725307/error-206-occures-on-junit-test-in-eclipse – Deeps Jan 28 '16 at 18:03
  • Set dynamic.classpath doesn't work for me. – Shofwan Feb 15 '18 at 05:44
  • Set dynamic.classpath doesn't work for me. It seems my change on workspace.xml didn't reflect immediately. What should I do? – Shofwan Feb 15 '18 at 05:45

2 Answers2

16

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.

Alexander Oh
  • 24,223
  • 14
  • 73
  • 76
  • 8
    changing the setting to `JAR Manifest` worked for me – jhilden Mar 12 '18 at 21:01
  • 3
    People panicking about "why doesn't my test work anymore" can try editing their tests run configuration in the drop-down called "Shorten command line". That's where the JAR Manifest option comes from. – Jason D Apr 24 '19 at 18:03
6

Go to Run -> Edit Configuration... -> Change Shorten Command Line to JAR manifest.

sorry_I_wont
  • 639
  • 1
  • 9
  • 16