I am installing Oracle JDK 8 in the machine as a root user in Ubuntu, But already Open JDK is installed in the machine.
# Install Oracle JDK
add-apt-repository ppa:webupd8team/java
apt-get -y update
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
apt-get install -y --force-yes oracle-java8-installer
# set JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-8-oracle
echo "export JAVA_HOME=${JAVA_HOME}" >> /etc/profile
echo "export PATH=$JAVA_HOME/bin:$PATH" >> /etc/profile
source /etc/profile
echo "Oracle JDK installation completed"
echo "echo JAVA_HOME: $JAVA_HOME"
I want to use Oracle JDK 8 for all Java process.
At the end of script, I am print JAVA_HOME. It is printed as expected like below
echo JAVA_HOME: /usr/lib/jvm/java-8-oracle
After installation is completed, I am logging into the machine as normal user. I see JAVA_HOME is set as openjdk as below:-
echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
Even I logged in as root user and I see the same as above.
How can I set Oracle JDK 8 as JAVA_HOME across all users?
I am not sure, Will Java applications running in that machines using Oracle JDK or OpenJDK?