JDK - environment variable

  1. /etc/profile , global
  2. /etc/profile.d/java.sh , global
  3. ~/.bashrc , user

java.sh

#!/usr/bin/env bash

export JAVA_HOME=/opt/apps/jdk1.8.0_161
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
  • source /etc/profile
  • source ~/.bashrc
java
javac
java -version