Set - Env - JDK - Maven - ubuntu

Set env for JDK and Maven ubuntu

  1. Edit /etc/profile
   sudo vi /etc/profile
  1. add below lines to the bottom
   #set maven env
   export M2_HOME=/usr/local/apache-maven-3.6.1
   export CLASSPATH=$CLASSPATH:$M2_HOME/lib
   export PATH=$PATH:$M2_HOME/bin
   #set Java environment
   export JAVA_HOME=/usr/lib/jdk1.8.0_191
   export JRE_HOME=$JAVA_HOME/jre
   export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
   export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
   
  1. activate the changes
   source /etc/profile
/etc/profile
  1. Edit bashrc
sudo vi ~/.bashrc
  1. add below lines in the front
   #set maven env
   export M2_HOME=/usr/local/apache-maven-3.6.1
   export CLASSPATH=$CLASSPATH:$M2_HOME/lib
   export PATH=$PATH:$M2_HOME/bin
   #set Java environment
   export JAVA_HOME=/usr/lib/jdk1.8.0_191
   export JRE_HOME=$JAVA_HOME/jre
   export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
   export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  1. activate the changes
   source ~/.bashrc