IDEA 10.5 Command line is too long

JavaIntellij IdeaTestngClasspath

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

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

enter image description here

Solution 3 - Java

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" />

Solution 4 - Java

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

Solution 5 - Java

See https://stackoverflow.com/questions/4853540/what-does-the-dynamic-classpath-flag-do-intellij-project-settings.

Not sure what you want to fix. If you need to avoid dynamic classpath, revise your dependencies, move libraries, project files and JDK to a directory with short path.

Edit: the bug you linked in comments makes sense, however what happens is that the command line when running your tests exceeds the OS limit even when using dynamic classpath. This can happen because of lots of command line arguments or options which cannot be shortened by IDEA, as IDEA can only workaround long classpath issue. There is nothing we can do about it, you should revise the way you pass parameters to your app so that the command line length is within limits.

From the IDEA side, we'll improve the handling of such case. This dialog will no longer be displayed when dynamic classpath is already used and you will get another error message about the long command line. I've submitted a new issue for this case.

Solution 6 - Java

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.

Solution 7 - Java

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

Solution 8 - Java

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.

Solution 9 - Java

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.

Solution 10 - Java

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

Solution 11 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionqinmiaoView Question on Stackoverflow
Solution 1 - Javauser7023213View Answer on Stackoverflow
Solution 2 - JavatechmagisterView Answer on Stackoverflow
Solution 3 - JavaMamad DansokoView Answer on Stackoverflow
Solution 4 - JavaSelvadurai HandeebanView Answer on Stackoverflow
Solution 5 - JavaCrazyCoderView Answer on Stackoverflow
Solution 6 - Javauser2233706View Answer on Stackoverflow
Solution 7 - JavaAlex.K.View Answer on Stackoverflow
Solution 8 - JavaGvSharmaView Answer on Stackoverflow
Solution 9 - JavariorioView Answer on Stackoverflow
Solution 10 - JavaeazyorganizerView Answer on Stackoverflow
Solution 11 - JavaGuilherme GehlingView Answer on Stackoverflow