java: supporting both Java 7 and Java 8

Users can now specify a Java version via the JAVA_VERSION environment
variable.