GlassFish4 a full JDK is required (Not Just JRE)

First time, when you upload page.jsp on domain and try to start, you can see

GlassFish4 a full JDK is required (Not Just JRE)

Parently when Glassfish is installed it hard-codes its reference to your JDK location, so to fix this problem I ended up having to edit a file named asenv.bat. In short, I edited this file:

C:\glassfish\config\asenv.bat:

and added a new reference to JDK 8, like this:

set AS_JAVA=C:\Program Files\Java\jdk1.8.0_121