As a non-Java developer, I am quit stuck in Java environment setting because I am not familiar with Java.
I write it down as following, I think it is the best way to write it in /etc/profile:
export JAVA_HOME=/usr/local/jdk1.8.0_111 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar