Early Access Program Features

IntelliJ IDEA: Configurable command line shortener

In IntelliJ IDEA, it’s possible to configure a command-line shortener. Let’s take a closer look at when and how to use this feature.

Configurable command line shortener

When the classpath gets too long, or you have many VM arguments, the program cannot be launched. The reason is that most operating systems have a command line length limitation. In such cases IntelliJ IDEA will try to shorten the classpath.

There are several approaches to shorten the classpath. Initially, IntelliJ IDEA tried to write the long classpath into the text file (which means an intermediate classloader to the application). But unfortunately, this didn’t work for some frameworks, e.g. JMock. Then, IntelliJ IDEA tried to use a more or less standard way, which was to pack the long classpath into the classpath.jar. Unfortunately, that didn’t work either, for some other frameworks.

And, sadly, there is no way to predict which kind of shortening would work for the user application. So the user is left having to make this decision. For Application, JUnit and TestNG configurations, v2017.3 provides a way to configure the shortener.

Starting with v2017.3, there is no more need to edit the settings of your IDE through the XML files.

IntelliJ IDEA 2017.3 provides a convenient way to specify the method to shorten command line, for each configuration.

Screen Shot 2017-10-09 at 08.58.33

In the Run/Debug Configuration dialog, a new field appeared: Shorten command line. The new field allows you to choose the way the IDE will shorten the command line from a drop-down list:

None: This is the default option. The IDE doesn’t shorten the long classpath. If the command line exceeds the OS limitation, the IDEA will not be able to run your application, but the tooltip will suggest configuring the shortener.

JAR Manifest: The IDE passes the long classpath via a temporary classpath.jar. The Original classpath is defined inside MANIFEST.MF as a Class-Path attribute in classpath.jar.

classpath file: The IDE will write a long classpath into a text file.

User-local default: Legacy property. This option is set automatically for projects created before this EAP. The IDE will configure this setting, depending on the value of the properties set in: idea/workspace.xml file, property: “dynamic.classpath” and idea.config.path/options/options.xml file, property: “idea.dynamic.classpath.jar”.
So you will have User-local default: none – if nothing was specified for the classpath shortener before, User-local default: JAR Manifest – if your settings specified the shortener via classpath, and User-local default: classpath file: – if your settings specified the shortener through the text file.

You can set up a default way to shorten the command line and use it as a template for further configurations. IntelliJ IDEA 2017.3 enables you to share your configuration with your colleagues, so all team members will have the same behavior for the application/tests, even on different operating systems. The only exception is for the parameter User-local default: this parameter won’t be shared if the configuration itself is shared. If you want the team to have the same experience, it’s advised to explicitly set this option.

Up until now, when the IDE shortened the classpath via classpath.jar, you would see only the classpath of the temporary jar: -classpath C:\Users\jetbrains\AppData\Local\Temp\classpath.jar.

Starting with IntelliJ IDEA 2017.3 you can preview the full command line if a long classpath was shortened via classpath.jar (JAR Manifest option in Run/Debug Configuration dialog box).

Screen Shot 2017-10-10 at 13.26.14

We love to hear from our users. Don’t forget to submit your feedback regarding this feature in IntelliJ IDEA.

Happy developing!

image description