4

I meet the problem of "CreateProcess error=87" and find the solution here. Fail to launch application (CreateProcess error=87), can't use shorten classpath workaround

I have already moved my project to root directory, but it still complain the classpath too long issue, and my proejct is maven styled, I can not remove any dependency. Is there any other way to shorten the classpath ?

Community
  • 1
  • 1
zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

1

We had the same issue in our project. The pain is that you need to explicitly list all jars on the classpath.

We've worked it around by implementing custom launcher class which takes a list of directories as an argument. In the launcher program you can read the list of jars in these directories, create a classloader and provide the list of your jars to it. Then use the classloader to run your actual program.

Of course the launcher could determine the list of required jars some other way, for example you can provide it in a file or however you like. The key of this solution is that you'll only need to provide classpath required for your launcher in the command line, not the entire classpath used by your actual program.

I hope this helps..

javadeveloper
  • 321
  • 1
  • 8