# JavaExec does not handle Spaces in Classpath

**URL:** <https://discuss.gradle.org/t/javaexec-does-not-handle-spaces-in-classpath/19558>\
**Category:** Bugs\
**Tags:** not-a-bug\
**Created:** [September 15, 2016, 3:17pm UTC](https://discuss.gradle.org/t/javaexec-does-not-handle-spaces-in-classpath/19558 "2016-09-15T15:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjstreet](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjstreet](https://discuss.gradle.org/u/jjstreet)\
**Post date:** [September 15, 2016, 3:17pm UTC](https://discuss.gradle.org/t/javaexec-does-not-handle-spaces-in-classpath/19558/1 "2016-09-15T15:17:01Z")

</div>

Gradle Version: _2.12, 2.14, 3.0_  
Operating System and JVM version: _Windows 10 x64, JDK 8_  
Is this a regression? If yes, which version of Gradle do you know it last worked for? _Not a regression_

This is related to open bug [GRADLE-1577](https://issues.gradle.org/browse/GRADLE-1577).

Gradle does not account for items in the classpath of a JavaExec task that contain spaces in their paths. Thus, running the command fails in windows because it incorrectly interprets the end of the classpath at the first space encountered.

Possible fix would be to use the `CollectionUtils.asCommandLine()` to handle transforming this classpath into a safe commandline argument before outputting it as part of the list of all JVM args in `JavaExecHandleBuilder`

---

<div class="post-metadata">

**Author:** ![jjstreet](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjstreet](https://discuss.gradle.org/u/jjstreet)\
**Post date:** [September 15, 2016, 5:55pm UTC](https://discuss.gradle.org/t/javaexec-does-not-handle-spaces-in-classpath/19558/2 "2016-09-15T17:55:45Z")

</div>

I did some more digging into this and determined that what I was seeing was not because of spaces. I may have actually been defeating whatever is being done to sanitize process arguments that contain spaces by trying to include my own quotes.

The topic should be considered invalid.

As for GRADLE-1577, it may also be ok (its a really old bug report) and may be closable.
