IDEA 10.5 Command line is too long
JavaIntellij IdeaTestngClasspathJava 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
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 :)
- On the edit configuration menu, click on modify options
- And then select Shorten command line
- Select JAR manifest option, apply & run
Solution 5 - Java
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
.
Solution 8 - Java
This is with Intelli J. I followed the below steps and i am able to run my tests.
- Go to Edit Configurations at the top menu of the editor.
- Under JUnits => click on modify Options.
- 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