简体   繁体   English

我的 Mac 上安装了多少个 Java 版本?

[英]How many java versions do i have installed on my Mac?

I'm a bit confused now.我现在有点困惑。 When I run the command java --version in the terminal i get: java 13.0.1.当我在终端中运行命令 java --version 时,我得到:java 13.0.1。 When I open the system preferences and click the java app and then about, i see it says Java version 8 1.8.0_231当我打开系统首选项并单击 java 应用程序然后单击时,我看到它说 Java 版本 8 1.8.0_231

Does that mean I have 8, 13 or both?这是否意味着我有 8 个、13 个或两者都有?

When I check through the java app.当我检查java应用程序时。

Java 应用程序面板

When I check through the terminal.当我通过终端检查时。

在此处输入图片说明

When i check for all JDK installed on my system (only 1 version pop ups).当我检查系统上安装的所有 JDK 时(仅弹出 1 个版本)。 在此处输入图片说明

You can have multiple JDK installed in one machine but you can have only one version set as default Java SDK.您可以在一台机器上安装多个 JDK,但您只能将一个版本设置为默认 Java SDK。 Looks like you have Java 13 set as default.看起来您已将 Java 13 设置为默认值。

Try running the following :尝试运行以下命令:

echo $JAVA_HOME

You can also go to the tab Java and see the list of all Java Runtime Environments (JRE.)您还可以转到 Java 选项卡并查看所有 Java 运行时环境 (JRE) 的列表。

Please note that just because you have multiple JREs available doesnot mean all corresponding SDK are also there.请注意,仅仅因为您有多个 JRE 可用并不意味着所有相应的 SDK 都在那里。

You can have many version of java on your Mac.您可以在 Mac 上安装多个版本的 Java。 But you can run only one of this in a process.但是您只能在一个进程中运行其中一个。 On my Mac, system preferences run with java path :在我的 Mac 上,系统首选项使用 java path 运行:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

But in terminal, this run with java path:但是在终端中,这与 java 路径一起运行:

/usr/bin/java /usr/bin/java

I think you can replace java file in /usr/bin by another version java you want.我认为你可以用你想要的另一个版本的 java 替换 /usr/bin 中的 java 文件。

that means you jdk version is 13 , and your jre version is 1.8.这意味着您的 jdk 版本是 13 ,而您的 jre 版本是 1.8 。

jre is used for running java apps ,and the jdk(java development kit) is for building apps with java language. jre 用于运行 java 应用程序,jdk(java 开发工具包)用于使用 java 语言构建应用程序。 java jdk is like the android sdk java jdk 就像 android sdk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM