仲灏小栈 仲灏小栈
首页
大前端
后端&运维
其他技术
生活
关于我
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

仲灏

诚意, 正心, 格物, 致知
首页
大前端
后端&运维
其他技术
生活
关于我
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Java

    • java初学者maven项目建立
    • Maven学习笔记
    • Untitled
    • idea 插件推荐
    • springboot项目学习笔记
    • springboot项目学习笔记2 用户模块
    • springboot项目学习笔记3 分类模块
    • springboot项目学习笔记4 商品模块
    • springboot项目学习笔记6 订单模块
    • 开源的物联网平台thingsboard部署
    • Docker 学习
    • java版本管理 jenv使用
      • 安装
      • 修改 .bash_profile 文件(手动版)
    • mac中安装卸载java
    • springboot学习上手
  • Docker

  • Jenkins

  • Nacos

  • SQL

  • Nginx

  • Windows

  • Linux

  • 虚拟机

  • Git

  • 网络

  • 其他

  • 后端&运维
  • Java
仲灏
2022-04-09
目录

java版本管理 jenv使用

# 安装

brew install jenv
1

image-20220315175118951

➜  Homebrew git:(stable) brew install jenv
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
kubekey

Error: The following directories are not writable by your user:
/usr/local/lib/pkgconfig
/usr/local/share/man/man8

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/lib/pkgconfig /usr/local/share/man/man8

And make sure that your user has write permission.
  chmod u+w /usr/local/lib/pkgconfig /usr/local/share/man/man8
➜  Homebrew git:(stable) sudo chown -R $(whoami) /usr/local/lib/pkgconfig /usr/local/share/man/man8
Password:
➜  Homebrew git:(stable) chmod u+w /usr/local/lib/pkgconfig /usr/local/share/man/man8
➜  Homebrew git:(stable) brew install jenv
Running `brew update --preinstall`...
==> Downloading https://ghcr.io/v2/homebrew/core/jenv/manifests/0.5.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jenv/blobs/sha256:521a1ad6e28b90f1e37893d279950e35957a0580464d639ec74c398f8da6d466
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:521a1ad6e28b90f1e37893d279950e35957a0580464d639ec74c398f8da6d466?se=2022-03-15T09%3A55%3A00Z&sig=i4RshcszFYJbg8upDLUjD%2FmuzZb1RrgB
######################################################################## 100.0%
==> Pouring jenv--0.5.4.all.bottle.tar.gz
==> Caveats
To activate jenv, add the following to your ~/.zshrc:
  export PATH="$HOME/.jenv/bin:$PATH"
  eval "$(jenv init -)"
==> Summary
🍺  /usr/local/Cellar/jenv/0.5.4: 84 files, 73KB
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/izhaong/Library/Caches/Homebrew/Cask/stats--2.6.22.dmg... (9.6MB)
Pruned 14 symbolic links and 2 directories from /usr/local

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

输入jenv versions (如下就安装成功了)

➜  Homebrew git:(stable) jenv versions
* system (set by /Users/izhaong/.jenv/version)
1
2
  • 安装pkg包

  • 安装后查看当前的包路径

    • /usr/libexec/java_home -V 此命令行可以罗列出电脑安装的所有版本的java

      • ➜  JavaVirtualMachines /usr/libexec/java_home -V
        Matching Java Virtual Machines (3):
            11.0.14 (x86_64) "Oracle Corporation" - "Java SE 11.0.14" /Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home
            1.8.311.11 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
            1.8.0_311 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
        /Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home
        
        1
        2
        3
        4
        5
        6
    • 把JAVA添加到 jEnv中jenv add /Library/Java/JavaVirtualMachines/JAVA_HOME

# 修改 .bash_profile 文件(手动版)

  1. 打开.bash_profile 文件
# 创建.bash_profile文件,若已存在则忽略
touch ~/.bash_profile
# 打开.bash_profile文件,以文本编辑的方式编辑
open ~/.bash_profile
1
2
3
4
  1. 编辑 .bash_profile 文件
# 设置 JDK 8
export JAVA_8_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home"

# 设置 JDK 11
export JAVA_11_HOME="/Library/Java/JavaVirtualMachines/jdk-11.0.14.jdk/Contents/Home"

# 默认JDK 8
export JAVA_HOME=$JAVA_8_HOME

# alias命令动态切换JDK版本
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"
1
2
3
4
5
6
7
8
9
10
11
12
  1. 保存.bash_profile 文件,重启终端
source .bash_profile 
1
上次更新: 2022/06/05, 20:31:36
Docker 学习
mac中安装卸载java

← Docker 学习 mac中安装卸载java→

最近更新
01
vim日常使用记录
04-02
02
滑动窗口最大值
04-02
03
有效的字母异位词
04-02
更多文章>
Theme by Vdoing | Copyright © 2021-2025 izhaong | github | 蜀ICP备2021031194号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式