Add JAVA_HOME and MAVEN_HOME to build.sh

Only updates PATH if not on Jenkins or Travis-CI.

JAVA_HOME is missing '/bin' because PATH requires 'bin' directories,
yet some applications use JAVA_HOME to access other resources from
Java.

fix bug 1054557