How to know if I am using Open JDK or Oracle JDK?

时间秒杀一切 提交于 2019-12-12 08:18:30

问题


Using java -version gives me this.

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Is it an OpenJDK or OracleJDK ?


回答1:


I think that you're using OracleJDK.

As I saw with a google search, the openJDK --version output is like this:

java -version

openjdk version "1.8.0-internal"

OpenJDK Runtime Environment (build 1.8.0-internal-0)

OpenJDK 64-Bit Zero VM (build 25.0-b20-internal, interpreted mode)

See: http://mail.openjdk.java.net/pipermail/jdk8-dev/2013-July/002840.html




回答2:


On debian, jessie-backports, openjdk-8:

openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
OpenJDK 64-Bit Server VM (build 25.66-b17, mixed mode)

Using the ubuntu ppa for oracle-java-8:

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

I would assume, the string "java" at the beginning denotes Oracle Java, whereas the OpenJDK gets you "openjdk".




回答3:


Call sun.misc.Version#println in java code will dump the version info to stderr. If you want to fetch the JDK version from java code.

package bj.tmp;

import sun.misc.Version;

public class Foo {
    public static void main(String[] args) {
        Version.println();
    }
}

Like this:

java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


来源:https://stackoverflow.com/questions/33895107/how-to-know-if-i-am-using-open-jdk-or-oracle-jdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!