In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to switch between the two versions of JDK in Linux. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
I have already configured a version 1.7 of jdk here.
Output commands:
Java-version [root@hu-hadoop1 sbin] # java-versionjava version "1.7.0,79" Java (TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot (TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
My configuration file is:
Vi / ect/profig1export JAVA_HOME=/home/bigdata/jdk1.7.0_79export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:export PATH=$PATH:$JAVA_HOME/bin:
Now let's import java JDK1.8.
Then enter the command:
Tar zxvf jdk-8u161-linux-x64.tar.gz
My decompression path is as follows:
/ home/bigdata/jdk1.8.0_161
Then run, set up and choose to use:
Alternatives-install / usr/bin/java java / home/bigdata/jdk1.8.0_161/bin/java 3alternatives-install / usr/bin/java java / home/bigdata/jdk1.7.0_79/bin/java 4
If you add an error, you can delete it using the following command:
Alternatives-remove java / home/bigdata/jdk1.7.0_79/bin
Then use the following command to switch the use of the two JDK:
Alternatives-config java
Then enter the command
Java-version [root@hu-hadoop1 jdk1.8.0_161] # java-versionjava version "1.8.0mm 161" Java (TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot (TM) 64-Bit Server VM (build 25.161-b12, mixed mode) [root@hu-hadoop1 jdk1.8.0_161] #
Here is the completion of the switch between the two versions of jdk.
Learn about alternatives
Enter the command:
Alternatives
Here are all the commands about it:
Alternatives-install [--initscript] [--slave] * alternatives-- remove alternatives-- auto alternatives-- config alternatives-- display alternatives-- set
Install means installation
Link is a symbolic link
Name is the identifier.
Priority indicates priority.
If you find that the version cannot be changed after the cut is completed, you can set the
Vi / etc/profile
JAVA_HOME comments in, and then reload the configuration file
Source / etc/profile
It is found that it is OK, and the java version is switched successfully.
Then you can change the configuration file back, reload it, and then it will be fine.
Change jdk and configure environment variables under PS:Linux
You don't need to delete the old jdk, install a new version of jdk, and then update the environment variables.
To install jdk under Linux, follow these steps
1: download the jdk package: this chapter uses files with the suffix tar.gz (no installation is required), such as jdk-8u111-linux-x64.tar.gz
2: save the jdk file to the directory under Linux: through the console, use the mkdir command to generate the usr/java directory and put the file under it.
3: extract the tar.gz file: through the console, go to usr/java, execute $tar-zxvf jdk-8u111-linux-x64.tar.gz, and extract it.
4: configure environment variables: open the console, run $sudo vi / etc/profile, insert the content to be configured at the end, press the Esc key, and enter (: wq save and exit)
JAVA_HOME=/home/gcs/user/java/jdk1.8.0_111PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport PATHexport CLASSPATH
5: run $source / etc/profile to make the configuration environment effective
6: run $java-version to see if it works. If the jdk version number appears, the installation and configuration of the environment variable is successful
The above is how to switch between the two versions of JDK in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.