Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to launch application (CreateProcess error=87), can't use shorten classpath workaround

When I launch our application in Eclipse on Windows I receive the following error:

Exception occured executing command line.

Cannot run program .. : CreateProcess error=87, The parameter is incorrect

I've solved this in the past by shortening the CLASSPATH.

I've now come to a point where I can no longer shorten the CLASSPATH, and would like to know if there are any other workarounds.

http://support.microsoft.com/kb/830473 seems to indicate that the max command prompt line length in windows xp is 8191 characters, and the only solution is to shorten folder names, reduce depth of folder trees, using parameter files, etc.

like image 806
Ivo Bosticky Avatar asked May 23 '10 23:05

Ivo Bosticky


4 Answers

This eclipsecoding FAQ page does confirm your diagnostic:

When the CLASSPATH gets too long, the program cannot be launched (at least under Windows) - try to shorten your classpath. In the case of a plugin, you can try to remove unnecessary required plugins.

And you have here a thread detailing the log errors.

Since you can launch Eclipse, but not the application, I would check if you don't have too many plugins included in your launch configuration. Could you check if you have added only the required plugins?

like image 154
VonC Avatar answered Nov 12 '22 09:11

VonC


As a workaround:

  1. Open your eclipse run configuration for the task that is failing.
  2. Choose the classpath tab, select the default classpath, click the "Edit.." button
  3. Check the "Only include exported entries" checkbox.

This allowed me to get around this problem on Eclipse 3.6 (Helios)

like image 43
Nick Avatar answered Nov 12 '22 11:11

Nick


I was dealing with the same problem on Eclipse, so, for that reason I decided to give a try to the same project on Intellij, just to know if it was a IDE problem.

Surprisingly, Intellij detects this problem (long classpath) and shows me a dialog, recommending me to use dynamic classpath feature. After enable this option, the problem gone.

What dynamic.classpath flag does is: What does the dynamic.classpath flag do? (IntelliJ project settings)

So, now my question is: Is there a way to do the same on Eclipse? seems to be a simple and elegant solution to this problems, instead of removing manually all those dependencies that are not necessary.

like image 2
Mauro Monti Avatar answered Nov 12 '22 11:11

Mauro Monti


This is definitely an issue with the classpath being too long causing the command line to exceed it's maximum limit. to resolve, shorten your classpath. If you are using Maven (like I was - e.g. in Jive development ) then change the location of your .m2 by changing the maven settings.xml

<settings>
  <localRepository>c:/.m2/repository</localRepository>
</settings>

and then move your repository there from the user directory, but ensure that the settings.xml and settings-security.xml (if applicable) are still in the User directory. This way the class path will no longer show c:\Documents and Settings\username.m2 over and over but rather c:.m2 allowing a significant decrease in classpath and thus command length. Remember that in windows you cannot create a directory (by yourself) with name .m2, and so you have to cut the directory, paste in in c: and then copy it back into your user folder

like image 2
Moe Avatar answered Nov 12 '22 09:11

Moe