12

I have the latest version of intellij 2018.1.1 and I am running a very basic maven project. I get an error message as "Command line is too long" when I try to run main. I updated the run config to JAR Manifest and now intellij doesnt pick up the latest changes in my java files. I am assuming it picks up a pre-made jar and doesnt re-compile? I am trying to figure out how to get intellij to work.

zooes
  • 1,280
  • 3
  • 15
  • 21
  • There are [multiple options](https://blog.jetbrains.com/idea/2017/10/intellij-idea-2017-3-eap-configurable-command-line-shortener-and-more/) to shorten the command line, try some other one. In case the issue persists, share the [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – CrazyCoder Apr 12 '18 at 11:29
  • Will do, thank you. Why does intellij not pick up the changes in the code though? – zooes Apr 12 '18 at 11:31
  • Hard to say without the MCVE. Check [idea.log/build.log](https://intellij-support.jetbrains.com/hc/articles/207241085) for errors. – CrazyCoder Apr 12 '18 at 11:33
  • Thanks, I looked through the logs, and I dont see any glaring errors. A sample light weight applications seems to be starting up just fine. It looks like the problem is when I have dependencies. I couldnt share my current project with you since its internal. Are there any other options I could try? – zooes Apr 12 '18 at 11:50
  • 1
    I have no command like args, so why does intellij think that its too long? – zooes Apr 12 '18 at 11:51
  • Try reproducing with a dummy project having similar structure. Try to delete `.idea` directory and reimport from Maven. – CrazyCoder Apr 12 '18 at 11:51
  • It's too long because the path of the command contains all the dependencies. – CrazyCoder Apr 12 '18 at 11:51
  • 1
    How do I check what command intellij is trying to use? – zooes Apr 12 '18 at 11:52
  • 1
    I have this issue only after upgrading. – zooes Apr 12 '18 at 12:02
  • Does this answer your question? [How to configure "Shorten command line" method for whole project in IntelliJ](https://stackoverflow.com/questions/47926382/how-to-configure-shorten-command-line-method-for-whole-project-in-intellij) – Maulzey Feb 04 '20 at 18:22

8 Answers8

32

To fix this, Edit the configuration the Run/Debug job in Intellij and select an appropriate "Shorten Command line" value that makes sense for your environment. Then try running the test again. If you are not sure about the correct value, simply try each of them till you get it to work. Here's a screenshot and the value that worked for me on Windows.

enter image description here

user6123723
  • 10,546
  • 18
  • 67
  • 109
5

In the newer versions of Intellij they've hidden the menu for shortening the command line by clicking "More Options" then select the Short Command Line.

Run configuration with Shorten command line menu

chubbsondubs
  • 37,646
  • 24
  • 106
  • 138
4

change project/.idea/workspace.xml from

<component name="PropertiesComponent">
    ...
</component>

to

<component name="PropertiesComponent">
    <property name="dynamic.classpath" value="true" />
    ...
</component>
koon
  • 61
  • 2
2

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>
Maulzey
  • 4,100
  • 5
  • 22
  • 30
1

Try to delete .idea folder and import the project again. Run 'mvn clean compile' and then run the main method.

swolf
  • 96
  • 6
0

I needed to add before launch settings to make it work with JAR Manifest option to shorten command line. This did the trick for me. Thanks for the quick responses!

zooes
  • 1,280
  • 3
  • 15
  • 21
0

I had the same issue and resolved it in :

  1. closing IntelliJ
  2. removing the .idea directory
  3. Reopening the project
Nicolas Dupouy
  • 450
  • 1
  • 7
  • 11
0

Each and every test method was failing with the "Command line is too long..." and the solution that worked for me was adding the below:

<component name="PropertiesComponent">
    ....
    <property name="dynamic.classpath" value="true" />
</component>
desertnaut
  • 57,590
  • 26
  • 140
  • 166
T. Mad
  • 31
  • 1