确定 Mac 上 Java SDK 的版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2992566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:21:13  来源:igfitidea点击:

Determining the version of Java SDK on the Mac

javamacos

提问by Ali_IT

I have a MacBook Pro running Snow Leopard; how can I see what version of the Java SDK is installed on my Mac?

我有一台运行 Snow Leopard 的 MacBook Pro;如何查看我的 Mac 上安装了哪个版本的 Java SDK?

采纳答案by Stefan Schmidt

In /System/Library/Frameworks/JavaVM.framework/Versionsyou'll see all the installed JDKs. There is a symbolic link named CurrentJDKpointing the active JDK.

/System/Library/Frameworks/JavaVM.framework/Versions您将看到所有已安装的JDK。有一个名为CurrentJDK指向活动 JDK的符号链接。

回答by mipadi

Which SDKs? If you mean the SDK for Cocoa development, you can check in /Developer/SDKs/to see which ones you have installed.

哪些 SDK?如果您指的是 Cocoa 开发的 SDK,您可以查看/Developer/SDKs/您安装了哪些SDK 。

If you're looking for the JavaSDK version, then open up /Applications/Utilities/Java Preferences. The versions of Java that you have installed are listed there.

如果您正在寻找JavaSDK 版本,请打开/Applications/Utilities/Java Preferences. 您已安装的 Java 版本在此处列出。

On Mac OS X 10.6, though, the only Java version is 1.6.

但是,在 Mac OS X 10.6 上,唯一的 Java 版本是 1.6。

回答by Jesper

Open a terminal and type: java -version, or javac -version.

打开终端并输入:java -version, 或javac -version

If you have all the latest updates for Snow Leopard, you should be running JDK 1.6.0_20 at this moment (the same as Oracle's current JDK version).

如果您拥有 Snow Leopard 的所有最新更新,那么此时您应该运行 JDK 1.6.0_20(与 Oracle 当前的 JDK 版本相同)。

回答by Rae

The simplest solution would be open terminal

最简单的解决方案是打开终端

$ java -version

it shows the following

它显示以下内容

java version "1.6.0_65"
  1. Stefan's solution also works for me. Here's the exact input:
  1. Stefan 的解决方案也适用于我。这是确切的输入:

$ cd /System/Library/Frameworks/JavaVM.framework/Versions

$ cd /System/Library/Frameworks/JavaVM.framework/Versions

$ ls -l

$ ls -l

Below is the last line of output:

下面是最后一行输出:

lrwxr-xr-x   1 root  wheel   59 Feb 12 14:57 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

1.6.0.jdk would be the answer

1.6.0.jdk 将是答案

回答by Jose Leonardo Rosero

Run this command in your terminal:

在终端中运行此命令:

$ java -version

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
Cristians-MacBook-Air:~ fa$ 

回答by Tim Keating

On modern macOS, the correct path is /Library/Java/JavaVirtualMachines.

在现代 macOS 上,正确的路径是/Library/Java/JavaVirtualMachines.

You can also avail yourself of the command /usr/libexec/java_home, which will scan that directory for you and return a list.

您也可以使用该命令/usr/libexec/java_home,它会为您扫描该目录并返回一个列表。