打开终端,输入:/usr/libexec/java_home -V
注意:输入命令参数区分大小写(-v
是不对的,必须是-V
),最下面的表示当前使用的默认JDK,看得出我的电脑安装了两个JDK
➜ ~ /usr/libexec/java_home -V Matching Java Virtual Machines (2): 1.8.0_161, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home 1.7.0_60, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home ➜ ~
安装目录在/Library/Java/JavaVirtualMachines/
文件夹下。
➜ ~ tree /Library/Java/JavaVirtualMachines -L 1 /Library/Java/JavaVirtualMachines ├── jdk1.7.0_60.jdk └── jdk1.8.0_161.jdk 2 directories, 0 files ➜ ~