When I try to install GlassFish or create a domain I get a "The system cannot find the path specified" error. Why?

When trying to install the GlassFish application server using :

ant -f setup.xml

some people have been faced with this error message :

create.domain:
[exec] The system cannot find the path specified.

The same error happens if you try to create the domain manually using

%asadmin create-domain

The solution is simply to properly set your

JAVA_HOME
environment variable and sticking to it.