Ubuntu18.04 installation JDK7

Direct download jdk installed archive

 

1. official website to download JDK   

     Address: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html

  Select the appropriate package download .gz 

2. decompression, placed in the specified directory (in jdk-7u60-linux-x64.gz Example)

  Create a directory:

sudo mkdir /usr/lib/jvm

 Add compression to the directory:

 sudo tar -zxvf jdk-7u60-linux-x64.gz -C /usr/lib/jvm

3. modify environment variables:  

sudo vim ~/.bashrc

 End of the file append the following contents:

Oracle jdk Environment #set 
Export the JAVA_HOME = / usr / lib / JVM / jdk1.7 .0_60 ## to be replaced is noted here that the directory own directory jdk extracting Export the JRE_HOME the JAVA_HOME = $ {} / JRE Export the CLASSPATH =:. $ { } the JAVA_HOME / lib: $ {} the JRE_HOME / lib the PATH = $ {Export the JAVA_HOME} / bin: $ the PATH

 The environment variables to take effect immediately

 source ~/.bashrc

4. Set the default jdk version

Copy the code
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_60/bin/java 300  
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_60/bin/javac 300 sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_60/bin/jar 300 sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7.0_60/bin/javah 300 sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0_60/bin/javap 300 
Copy the code

 Then execute:

sudo update-alternatives --config java

    If the initial installation jdk, there will be the following tips     

   There is only one alternative in link group java (providing /usr/bin/java):
    /usr/lib/jvm/jdk1.7.0_60/bin/java

 No person, choose the right jdk

5. Test jdk

Copy the code
java -version

java version "1.7.0_60"

  Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
  Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

Copy the code

  jdk installation is successful

Guess you like

Origin www.cnblogs.com/jiangjh/p/10959812.html