MacOS查看JDK版本或卸载

2023-12-13 18:47:42
  1. 查看当前配置的JDK版本
    java -version 
    java version "1.8.0_211"
    Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
    
  2. 查看已安装的JDK版本
     /usr/libexec/java_home -V
     # 输出
     Matching Java Virtual Machines (5):
    21.0.1 (x86_64) "Oracle Corporation" - "Java SE 21.0.1" /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home
    17.0.9 (x86_64) "Oracle Corporation" - "Java SE 17.0.9" /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
    11.0.21 (x86_64) "Oracle Corporation" - "Java SE 11.0.21" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
    1.8.211.12 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_211 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
    
  3. 删除JDK
    # 进入指定目录
    cd /Library/Java/JavaVirtualMachines
    # 删除
    sudo rm -rf <要删除的目录>
    
  4. 清除环境变量
    若要配置新的JDK,需要修改 bash_profile 文件环境变量,然后 source .bash_profile使其生效。

文章来源:https://blog.csdn.net/nathan_csdn/article/details/134839307
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。