When I run tests I get the error "Command line is too long". It works if I set the "Shorten command line" method in the Run/Debug configuration to "JAR manifest" for the specific method or class, but how do I set it for the whole project or is there an IDE global setting for it?
13 Answers
Inside your .idea folder, change workspace.xml file
Add
<property name="dynamic.classpath" value="true" /> to
<component name="PropertiesComponent"> . . . </component> Example
<component name="PropertiesComponent"> <property name="project.structure.last.edited" value="Project" /> <property name="project.structure.proportion" value="0.0" /> <property name="project.structure.side.proportion" value="0.0" /> <property name="settings.editor.selected.configurable" value="preferences.pluginManager" /> <property name="dynamic.classpath" value="true" /> </component> If you don't see one, feel free to add it yourself
<component name="PropertiesComponent"> <property name="dynamic.classpath" value="true" /> </component> Community edit: this solution does not seem to work in newer versions of IDE, the format of PropertiesComponent is different now. If that's your case, then this answer should work
3 Comments
Intellij 2018.2.5
Run => Edit Configurations => Choose Node on the left hand side => expand Environment => Shorten Command line options => choose Classpath file or JAR manifest
3 Comments
You can set up a default way to shorten the command line and use it as a template for further configurations by changing the default JUnit Run/Debug Configuration template. Then all new Run/Debug configuration you create in project will use the same option.
Here is the related blog post about configurable command line shortener option.
6 Comments
The latest 2020 build doesn't have the shorten command line option by default we need to add that option from the configuration.
Run > Edit Configurations > Select the corresponding run configuration and click on Modify options for adding the shorten command-line configuration to the UI. 
Select the shorten command line option 
Now choose jar manifest from the shorten command line option 
2 Comments
Thanks to Rajesh Goel in Android Studio:
Run > Edit Configurations...
Select a test (better to select a parent test class) and set a Shorten command line: option to classpath file. Then OK (or Apply, OK).
2 Comments
shorten command line worked for me.If you use JDK version from 9+, you should select
Run > Edit Configurations... > Select JUnit template.
Then, select @argfile (Java 9+) as in the image below.
If you don't see the Shorten command line, then just clicking on Modify options menu as below, and select the Shorten command line
Please try it. Good luck friends.
Comments
Add <property name="dynamic.classpath" value="true" /> to the .idea/workspace.xml file under the <component name="PropertiesComponent"> tag. That worked for me.
1 Comment
In my case, the error was:
Error running 'MasterFileGenerator': Command line is too long. Shorten command line for StagingFileGenerator or also for Application default configuration. The solution was to switch to go to "Run/Debug Configurations" and switch from user-local default: none - java [options] className [args] to JAR manifest - java -cp classpath.jar className [args].
Comments
To have it persisted:
- Open Intellj
- ctrl+shift+n
- Type workspace.xml
- Find component name="PropertiesComponent" tag
- a) in case there are list of properties, add
<property name="dynamic.classpath" value="true" />
b) in case there is keyToString json, add new line in the map:
"dynamic.classpath": "true" (remember about comma in the upper line)
- (optional) If you want to have this config enabled also in another project immediately, restart intellj










