Reputation: 47
Where is the recommended place to install the jdk .tar.gz file I just downloaded? I want it to be available for all users.
The installation guides that I have found told me to extract the jdk in many different places, such as /opt
, /usr/lib
and /usr/local
. But the which one is the "right" choice? Why?
Upvotes: 2
Views: 16368
Reputation: 51
First Download the Oracle JDK Download Oracle JDK or Open JdkDownload Open JDK, then follow these commands :
First Unzip the tar file with this following command
tar zxvf <tar file name>
Like : tar zxvf jdk-11.0.2.jdk
enter your password if asked
Now set the JAVA_HOME
i.e system variables to the end of /etc/profile
file
first, open /etc/profile : vi /etc/profile
and press I to insert and put this at the end
export JAVA_HOME=<Directory where JAVA has been extracted>
export JAVA_HOME=/home/jdk-10.0.2.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
now press ESC + SHIFT + :WQ
to save the changes
Upvotes: 4
Reputation: 6216
For installation from the JDK tar.gz use the following command to unpack the tarball to the desired directory where you need to install java :
tar zxvf jre-8u73-linux-x64.tar.gz
Then you can set the java home by editing the environment file and set java home like :
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
where the latter part is the directory in which you have installed java.Usually java will be installed in the /usr/lib/
.Use an editor like nano or vim to edit the file and add the above key value to set java home.
Upvotes: 2
Reputation: 4379
Into /usr/lib/jvm/
folder, the reason is because the default installation path is that one when you use the sudo apt install
command, which makes total sense to me.
Example:
OpenJDK 11 is located at : /usr/lib/jvm/java-11-openjdk-amd64/bin/java
OpenJDK 8 is located at : /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
For more information, you can read this article here.
Upvotes: 6