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

Instance scenario application (sun JDK1.7 and sun JDK1.8 switch alternatives)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Java is used to execute java programs (java runtime environment)

Javac is used in java program compilation (java program development environment)

Step 2: alternatives install JDK

# alternatives-install / usr/bin/java java / usr/local/jdk version / bin/java 1

# alternatives-install / usr/bin/javac java / usr/local/jdk version / bin/javac 2

Step 2: view the available version information

# alternatives-display java

# alternatives-display javac

Step 3: switch the java version

# alternatives-config java

# alternatives-config javac

Delete the jdk version (optional, use-- remove when you need to delete)

# alternatives-remove java/ usr/local/java/jdk version / bin

# alternatives-remove javac / usr/local/java/jdk version / bin

Step 4: modify the jdk runtime environment of the current user

# echo export JAVA_HOME=/usr/bin/java > > ~ / .bash_profile

Echo export PATH=$PATH:$JAVA_HOME/bin > > ~ / .bash_profile # source ~ / .bash_profile

Note that you need to comment out the JAVA_HOM in the / etc/profile file

View and manage JAVA_HOME

Echo $JAVA_HOME

/ usr/local/jdk

Java-version

Java version "1.8.0,111"

Java (TM) SE Runtime Environment (build 1.8.0_111-b14)

Java HotSpot (TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

# instance [cqs@centos7 jdk] $echo 'export JAVA_HOME=/usr/bin/java' > ~ / .bash_ profile [CQs @ centos7 jdk] $echo' export PATH=$PATH:$JAVA_HOME/bin' > > ~ / .bash_ profile [CQs @ centos7 jdk] $source ~ / .bash_profile

Note that you need to comment out the JAVA_HOM in the / etc/profile file

[cqs@centos7 jdk] $echo $JAVA_HOME

/ usr/bin/java

[cqs@centos7 jdk] $echo $PATH

/ usr/local/bin:/usr/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/home/cqs/.local/bin:/home/cqs/bin:/usr/bin/java/bin

Step 1: alternatives install JDK1.7 (link path [link]: / usr/bin/java link name [name]: java application JAVA actual path [path]: / home/cqs/data/jdk/jdk1.7.0_80/bin/java priority [priority]: 1) [cqs@centos7 jdk] $sudo alternatives-- install / usr/bin/java java ~ / data/jdk/jdk1.7.0_80/bin/java 1 [cqs@centos7 jdk] $sudo alternatives-- config java

There is 1 program that provides' java'.

Selection Command

* + 1 / home/cqs/data/jdk/jdk1.7.0_80/bin/java

Enter to keep the current selection [+], or type selection number:

[cqs@centos7 jdk] $java-version

Java version "1.7.080"

Java (TM) SE Runtime Environment (build 1.7.0_80-b15)

Java HotSpot (TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Alternatives install JDK1.8

[cqs@centos7 jdk] $sudo alternatives-install / usr/bin/java java ~ / data/jdk/jdk1.8.0_161/bin/java 2 [cqs@centos7 jdk] $sudo alternatives-config java

There are 2 programs which provide 'java'.

Selection Command

1 / home/cqs/data/jdk/jdk1.7.0_80/bin/java

2 / home/cqs/data/jdk/jdk1.8.0_161/bin/java

Enter to keep the current selection [+], or type selection number: 2

[cqs@centos7 jdk] $java-version

Java version "1.8.0,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)

[cqs@centos7 jdk] $sudo alternatives-- config java

There are 2 programs which provide 'java'.

Selection Command

1 / home/cqs/data/jdk/jdk1.7.0_80/bin/java

* + 2 / home/cqs/data/jdk/jdk1.8.0_161/bin/java

Enter to keep the current selection [+], or type selection number: 1

[cqs@centos7 jdk] $java-version

Java version "1.7.080"

Java (TM) SE Runtime Environment (build 1.7.0_80-b15)

Java HotSpot (TM) 64-Bit Server VM (build 24.80-b11, 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

Servers

Wechat

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

12
Report