IDEA 10.5 Command line is too long

141,107

Solution 1

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

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

enter image description here

Solution 3

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

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

See 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.

Share:
141,107
qinmiao
Author by

qinmiao

software test engineer

Updated on January 17, 2022

Comments

  • qinmiao
    qinmiao over 2 years

    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?

  • qinmiao
    qinmiao almost 13 years
    i see it.when i set dynamic.classpath=true,the Command line is still too long
  • CrazyCoder
    CrazyCoder almost 13 years
    In this case it's a bug which should be reported at youtrack.jetbrains.net/issues/IDEA.
  • thijsraets
    thijsraets over 6 years
    Now you can set "Shorten command line" to "JAR manifest" under your default JUnit configuration.
  • patrik
    patrik about 6 years
    I have not seen this in Linux (or it might have to do with Java 9). However I do not start to do refactoring of the project. More precise I am not allowed to. Do you have any other advice?
  • user7023213
    user7023213 over 5 years
    if one makes a global junit config with same settings then it wont be necessary to do this setting for all individual test config one is running!
  • Vijai
    Vijai over 4 years
    To reach it from Intellij Top menu use "Run => Edit Configurations"
  • Doogle
    Doogle over 3 years
    Thanks for the details this really works tried and tested some bug in intellij i guess not picking correctly this helps.
  • simno
    simno over 3 years
    If you don't see this option in the menu press "Modify options v Alt+M" dropdown menu and check "Shorten command line" option to show it (IDEA CE 2020.3).
  • elect
    elect over 3 years
    This doesnt look to be available anymore on the last Idea 2020.3
  • Nathan
    Nathan about 3 years
    I'm running IntelliJ IDEA Ultimate 2020.3. This option was available (and solved the problem for me).
  • JSON derulo
    JSON derulo about 3 years
    @elect the option is there in 2020.3: Edit Configurations -> "Configurations" tab -> Environments
  • cnmuc
    cnmuc about 3 years
    If you don't see option "Shorten command line", click on "Modify Options" and check "Shorten command line"
  • Radek Konrad Furmański
    Radek Konrad Furmański about 2 years
    The fix also worked for me, but on WINDOWS the intellij had problems with picking up any updates to the code. So I reduced the length of the path of the repository C:/user/repository/lots-of-other-characters-and-sub-paths to C:/user/repository/not-so-many-of-other-characters-and-sub-p‌​aths. By leveraging that solution the "Shorten command" option was no longer needed and now the changes are properly taken into consideration by the IDE
  • rios0rios0
    rios0rios0 almost 2 years
    It still works on the 2022.1.2. Just the path is a little bit different. You need to "Modify options" near the title "Build and run".
  • datsb
    datsb almost 2 years
    The entire path Run > Edit Configurations > "shorten command line" works for me, except that instead of "classpath file" I needed "JAR manifest" (otherwise some XML resource files would not be found). IntelliJ IDEA 2022.1.1 CE
  • datsb
    datsb almost 2 years
    "JAR manifest" (instead of Classpath) is what worked for me. IntelliJ IDEA 2022.1.1 CE