Monday, September 12, 2011

Eclipse in Windows: Cannot run program (CreateProcess error=87), The parameter is incorrect

You will see this when you exceed the character limits on Windows machine in your Java classpath. The character limit for the Windows is the following:

- Windows XP: 8189 characters
- Windows 7: around 33k characters

You will have to somewhat shorten the classpath. There are potential work arounds to this problem.

1) Use the network drive to shorten the classpath

You can use the network drive to shorten the classpath. Instead of having C:\Program Files\Apache\Maven 3.0\....\\xxx.jar, you can shorten the entire path to (i.g. M:\xxx.jar). Make sure to update your Maven's settings.xml and configure your m2clipse settings accordingly.


2) Use -Djava.ext.dirs JVM parameter and exclude Maven dependencies from your run configuration

It's possible that you might still run into exceeding the class path issue even after setting up the network drive. If this is the case, follow the below steps to resolve the issue.

You can use maven's dependency plugin to export all the transitive dependency jars into the specific location. Look Maven dependency plugin. Configure the Maven dependency plug-in on your pom then execute "mvn dependency:copy-dependencies" to export the jars into the folder (i.e. libs).

Once you have exported all the jars, navigate your Eclipse's runtime configurations. Go to Arguents -> VM arguments and add the -Djava.ext.dirs=libs (if your jar folder is libs). Note that this VM argument is separated by ; so you can enter multiple folders.