zoukankan      html  css  js  c++  java
  • 关于Linux系统下jdk版本切换问题(alternatives命令的使用)

    [root@danny lib]# cd /usr/lib/jvm
    [root@danny jvm]# 
    [root@danny jvm]# ls
    java                                                java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64        jre-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64
    java-1.7.0                                          java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug  jre-1.8.0
    java-1.7.0-openjdk                                  java-openjdk                                           jre-1.8.0-openjdk
    java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64  jre                                                    jre-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
    java-1.8.0                                          jre-1.7.0                                              jre-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug
    java-1.8.0-openjdk                                  jre-1.7.0-openjdk                                      jre-openjdk
    [root@danny jvm]# ll
    total 12
    lrwxrwxrwx  1 root root   26 Nov  5 13:27 java -> /etc/alternatives/java_sdk
    lrwxrwxrwx  1 root root   32 Nov  5 13:27 java-1.7.0 -> /etc/alternatives/java_sdk_1.7.0
    lrwxrwxrwx  1 root root   40 Nov  5 13:27 java-1.7.0-openjdk -> /etc/alternatives/java_sdk_1.7.0_openjdk
    drwxr-xr-x 10 root root 4096 Nov  5 13:27 java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64
    lrwxrwxrwx  1 root root   32 Sep  5 16:54 java-1.8.0 -> /etc/alternatives/java_sdk_1.8.0
    lrwxrwxrwx  1 root root   40 Sep  5 16:54 java-1.8.0-openjdk -> /etc/alternatives/java_sdk_1.8.0_openjdk
    drwxr-xr-x  9 root root 4096 Nov  5 13:40 java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
    drwxr-xr-x  9 root root 4096 Sep  5 16:54 java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug
    lrwxrwxrwx  1 root root   34 Nov  5 13:27 java-openjdk -> /etc/alternatives/java_sdk_openjdk
    lrwxrwxrwx  1 root root   21 Nov  5 13:27 jre -> /etc/alternatives/jre
    lrwxrwxrwx  1 root root   27 Nov  5 13:27 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
    lrwxrwxrwx  1 root root   35 Nov  5 13:27 jre-1.7.0-openjdk -> /etc/alternatives/jre_1.7.0_openjdk
    lrwxrwxrwx  1 root root   54 Nov  5 13:27 jre-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64 -> java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre
    lrwxrwxrwx  1 root root   27 Sep  5 16:54 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
    lrwxrwxrwx  1 root root   35 Sep  5 16:54 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
    lrwxrwxrwx  1 root root   51 Sep  5 16:54 jre-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64 -> java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre
    lrwxrwxrwx  1 root root   57 Sep  5 16:54 jre-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug -> java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug/jre
    lrwxrwxrwx  1 root root   29 Nov  5 13:27 jre-openjdk -> /etc/alternatives/jre_openjdk
    [root@danny jvm]# ls /etc/alternatives/java_sdk
    bin  demo  include  jre  lib  sample  src.zip  tapset
    [root@danny jvm]# alternatives
    --config java (版本切换) There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug/jre/bin/java) *+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java) (当前版本) 3 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre/bin/java) Enter to keep the current selection[+], or type selection number: 3 (切换为1.7版本) [root@danny jvm]# alternatives --config java (以下可以看到+号在1.7版本处,不变还是输入3退出) There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64-debug/jre/bin/java) * 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java) + 3 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre/bin/java) Enter to keep the current selection[+], or type selection number: 3 [root@danny jvm]# java -version (可以看到已经变为1.7版本了) java version "1.7.0_191" OpenJDK Runtime Environment (rhel-2.6.15.4.el7_5-x86_64 u191-b01) OpenJDK 64-Bit Server VM (build 24.191-b01, mixed mode)

    注释:在探究linux中jdk版本切换时发现了如下一行

    lrwxrwxrwx  1 root root   26 Nov  5 13:27 java -> /etc/alternatives/java_sdk

    网上搜了以下alternatives这个文件是什么东东时,才发现这是一个可以进行jdk版本切换的命令,命令格式如下:

    alternatives --config java
  • 相关阅读:
    Asp.net弹出浏览器客户端确认对话框代码 Carlwave
    VS 2005 与SQL Server 2005整合优势在哪里?(from csdn.net) Carlwave
    如何让搜索引擎收录我的站点 Carlwave
    超强扩展性的DNNDotNetNuke模块功能分类列表(from 中国DNN) Carlwave
    DotNetNuke命名空间概述 Carlwave
    Most Popular Questions and Answers on ASP.NET Whidbey(from asp.net forums,write by ASP.NET Team) Carlwave
    火箭官方宣告麦蒂缺阵五周 季后赛前景蒙上阴影 Carlwave
    asp.net有效使用缓存(转) Carlwave
    《Business Rules Engine Overview》《业务规则引擎概述》write by Mark Kamoski Carlwave
    中国详细省市县自治区名称列表(含access数据库和sql2000备份数据库) Carlwave
  • 原文地址:https://www.cnblogs.com/dannylinux/p/9908775.html
Copyright © 2011-2022 走看看