in Java

Gradle’s bootRun and Window’s command length limit

Sometimes Gradle’s bootRun and Window’s command length limit are two opponents. If you use bootRun to start your Spring Boot app from Gradle all class path dependencies will be added to the start command. Gradle will run something like this in the end:

That’s fine and will work for a really long time. But as longer you work on your project you will add more and more dependencies. And it might happen that you cross a secret line of no return: 32767. That’s the number of characters which Windows’ CreateProcess function will accept. Any additional character will cause an exception:

Sh*t! So how to start your app? With Gradle, you can use a simple work around: Instead of appending all your dependencies to the start command, you create a JAR file with a manifest file. This manifest file contains all dependencies and will be the only dependency in your start command:

In Gradle code, this looks like this:

The pathingJar task creates a JAR file with a manifest file containing all our dependencies. This file will become pretty big, but that’s totally fine. Now we only extend the bootRun task to use this pathing JAR. This will solve the problem.

Best regards,


  • Krishnamoorthy Damodaran

    You saved my day.. Thanks.. It works like gem..

  • Øyvind Horneland

    Great stuff! 😀

  • Levent Aksu

    This is getting me an error and I am not sure how to work that out as I am 0 on groovy:

    build file ‘’: 104: expecting ”’, found ‘r’ @ line 104, column 67.
    ).replaceFirst(/file:/+/, ‘/’)

    1 error

    • Toni mas

      you have to scape 2nd slash in the regex replaceFirst(/file:/+/, ‘/’)

  • ditrich

    Alternative is to use Long Path Tool.It works for this issue.

  • Alonso del Villar

    Ok, im new to gradle, i have my build.grade and this code on this article, where do i put the code? in the build.gradle? and can i continue using gradle bootRun?