Updated sequence of setting JAVA_HOME on image build