Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Replace the java environment from the installed version of openjdk to Oracle's jdk in ubuntu

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

View the version of JDK installed on the system

Root@ubuntu:~# java-version

Java version "1.7.079"

OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu1)

OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

two。 Upload JDK to the / opt directory

Root@ubuntu:~# cd / opt

Root@ubuntu:/opt# ls

Jdk-6u45-linux-x64.bin

3. Modify the permissions of JDK

Root@ubuntu:/opt# chmod + x jdk-6u45-linux-x64.bin

4. Execute JDK file

Root@ubuntu:/opt#. / jdk-6u45-linux-x64.bin

5. View the extracted directory

Root@ubuntu:/opt# ls

Jdk1.6.0_45 jdk-6u45-linux-x64.bin

6. Create a soft link

Root@ubuntu:/opt# ln-s jdk1.6.0_45/ java

Root@ubuntu:/opt# ls

Java jdk1.6.0_45

7. Modify the environment variable configuration file

Root@ubuntu:/opt# vim / etc/profile

# set java environment

Export JAVA_HOME=/opt/java

Export JRE_HOME=/opt/java

Export CLASSPATH==.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib

Export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

8. Let the configuration file take effect

Root@ubuntu:/opt# source / etc/profile

9. View the version of java

Root@ubuntu:~# java-version

Java version "1.7.079"

OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu1)

OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

10. View the newly configured JAVA version

Root@ubuntu:~# / opt/java/bin/java-version

Java version "1.6.045"

Java (TM) SE Runtime Environment (build 1.6.0_45-b06)

Java HotSpot (TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

11. Create a link

Root@ubuntu:~# update-alternatives-install / usr/bin/java java/ opt/java/bin/java 300

Root@ubuntu:~# update-alternatives-install / usr/bin/javac javac / opt/java/bin/javac 300

Update-alternatives: using / opt/java/bin/javac to provide / usr/bin/javac (javac) in auto mode

twelve。 Configure the system's default JAVA environment

Root@ubuntu:~# update-alternatives-config java

There are 2 choices for the alternative java (providing / usr/bin/java).

Selection Path Priority Status

* 0 / usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode

1 / opt/java/bin/java 300 manual mode

2 / usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode

Press enter to keep the current choice [*], or type selection number: 1

Root@ubuntu:~# update-alternatives-config javac

There is only one alternative in link group javac (providing / usr/bin/javac): / opt/java/bin/javac

Nothing to configure.

13. Check to see if it is effective

Root@ubuntu:~# java-version

Java version "1.6.045"

Java (TM) SE Runtime Environment (build 1.6.0_45-b06)

Java HotSpot (TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report