I’m sure that you know what to do, but this did not work,
Hm, strange, sorry.
The whole point of javaw
vs. java
is, that no console window is shown.
Seems to still be different when using a batch script.
With using start
you do not even need to use javaw
, but can also use java
, so it would be this (tested this time
):
tasks.startScripts {
doLast {
windowsScript
.readText()
.replace("""^(?="%JAVA_EXE%")""".toRegex(RegexOption.MULTILINE), """start "" /min """)
.let(windowsScript::writeText)
}
}
But as javaw
also shows dialog boxes on errors, it might still be better to replace java
by javaw
, so I would recommend
tasks.startScripts {
doLast {
windowsScript
.readText()
.replace("java", "javaw")
.replace("""^(?="%JAVA_EXE%")""".toRegex(RegexOption.MULTILINE), """start "" /min """)
.let(windowsScript::writeText)
}
}
With the only single change I intended, all the checks before are not obsolete. The change is after the “:execute” jump mark (to be exactly: the line were java actually called only), and this can only reached as the checks before are fine with no problem.
That’s exactly the point.
You let it first do the discovery which Java to use for execution, and then at the line where you would execute the discovered result, you just throw away the result of the work done previously and just use javaw
from PATH
and only if it is available there.
I’m a little confused about the ‘/’ as linux styled path separator and surprised that I get java called and not an error message. In special because the doubled path separator “/”. Is this intended to be so?
In what you show there is no double-separator, as you did not use verbatim formatting:

But knowing that this is the case in this forum software I know what you mean, which is caused by your JAVA_HOME
ending with a path separator.
That forward and backward slashes are mixed is a minor nit in the Gradle-built-in template for that script.
It might be a bit cleaner to use backslashes, feel free to post an issue report or pull request that fixes it, but it works either way, cmd.exe is just intelligent enough to understand it it seems.