How to install Oracle Java?
At first, we have to add an PPA by using the sudo add-apt-repository ppa:webupd8team/java for installing the latest Oracle Java as Java7 or Java8 in Ubuntu.
To update package list again by using sudo apt-get update command
If we want to install Oracle Java7, we can execute the sudo apt-get install oracle-java7-installer command. (# 1)Of course, if we want to install Oracle Java8, we can execute the sudo apt-get install oracle-java8-installer command.
When the installation finish and success, we can realize which version will be used later by using the java -version command
As you know, if there is more than one version of Java,we have to choose one Java version to use in the system.
How to do it?
By using the sudo update-alternatives --config java command next to select one version as the following choice for us. (# 2)So do that we also can understand the path of the java installation. If we have this information,we can set the “JAVA_HOME” and “JRE_HOME” environment variable later.
How to do it? At first, we need to know what is value on the “JAVA_HOME” variable by using the echo $JAVA_HOME command or “JRE_HOME” variable by using the echo $JRE_HOME command As the above result, there is no any setting in this system now.
In the moment, we have already changed the default java to Java8 so that the java full path is /usr/lib/jvm/java-8-oracle/jre/bin/java
As to the environment variable setting, we have two method to do it.
For every user, we can set the environment variable by editing the /etc/profile file
For a particular user, we can set the environment variable by adding something in the end of the /home/<users>/.bashrc file
To reload this file and test it by using the echo $JAVA_HOME or echo $JRE_HOME command again
It will return the set path so that the environment variable has been set successfully.Until now, we have already finished the Oracle JAVA installation and the environment variable setup.
Reference :
(# 1) Due to the WebUpd8 Oracle Java PPA doesn’t include any java binary files, it will help us to download and install Oracle Java automatically. In the installation process, we have to accept the license agreement as follows to go ahead.(# 2) As to change the Java compiler(javac), it has a little different that just replace java with javac word as the
sudo update-alternatives --config javac command.
沒有留言:
張貼留言