IDEA 10.5 Command line is too long

Viewed 176947

In Maven project when I run test case (on Windows):

Error running TestApp.readParameter: Command line is too long. In order to reduce its length classpath file can be used. Would you like to enable classpath file mode for all run configurations of your project? Enable

set .iws

<property name="dynamic.classpath" value="true" />

How this could be fixed?

12 Answers

In Intellij, go to "edit configurations" (Run -> Edit Configurations), in the configuration tab that comes up in the line "shorten command line" select option "classpath file"/"@argFiles (Java 9+)", last option in the drop down menu. Fixed it for me.

Setting the Shorten command line:JAR manifest in Run/Debug Configurations resolves the issue.

enter image description here

Open the file .idea/workspace.xml file from your project root folder, go to section

<component name="PropertiesComponent">

and add the following:

<property name="dynamic.classpath" value="true" />

Did this on Intelij community 2021.1 windows, Worked fine :)

  1. On the edit configuration menu, click on modify options

  1. And then select Shorten command line

  1. Select JAR manifest option, apply & run

enter image description here

enter image description here

i set Shorten command line from none => JAR mainfest and it work, hope userful

The options mentioned in the answers aren't available in the version I'm using, 2020.2. I clicked on the "Enable" link shown in the message, and that fixed this issue for me.

In my case fix was to update Run/Debug Configurations and select in Shorten command line the next option classpath file. enter image description here

This is with Intelli J. I followed the below steps and i am able to run my tests.

  1. Go to Edit Configurations at the top menu of the editor.
  2. Under JUnits => click on modify Options.
  3. Under java => select "Shorten Command" => Select "JAR Manifest option.

It solved me.

I was struggling with this error for a long time and none of the other answered helped.

The thing that solved the issue was adding the following line to the pitest configuration in the Gradle:

useClasspathFile = true

So now the build.gradle file has such an entry:

 pitest {
    threads = 4

    //adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5"
    junit5PluginVersion = '0.12'

    useClasspathFile = true    <------------------------------

    targetClasses = ["com.example.service.*"]

    if (project.name in ['no-need-to-mutate-module']) {
        failWhenNoMutations = false
    }
}

Here is the link to the post that helped me.

I was also having this problem and the fix was to add the skipTests flag after noticing a lot of the test dependencies were on the class path;

mvnw.cmd -DskipTests=true package

I had this problem using the community version. I managed the problem by running the project with the Maven configuration.

spring-boot:run -Dspring.profiles.active=local

Intellij Maven Configuration

Related