Oracle changed the license for its Java releases:
I suppose that all Oracle releases of Java 7 and below were OBCL; I'm not sure if there were any Oracle Java 9+ releases under that old license.
Of course, other Java distributions (OpenJDK, etc.) have still other licenses.
Is there a way for a running program to determine the license of the underlying JVM/JRE? Motivation: I'd like to warn users of my program when they're using my program on a JVM/JRE of specific license(s).
I've been unable find to find any standard system property with this information, and I also looked in the manifests of the JARs that constitute the JRE.
There are a couple places that provide structured access to the Java version:
IS_JAVA_1_8
, etc.The former doesn't get down to the detail of the the update number, and the latter is only available in Java 9+. In any case, both still require some other resource to map known Java versions to their respective licenses.
Also: I'm aware of Oracle's latest recommendation of bundling a JRE with one's application, and that this issue can be avoided that way.
Redistribution of the Java SE Runtime Environment (JRE)Current releases of the Oracle Java SE 8 Runtime Environment require a commercial license for redistribution.
Oracle has announced that from January 2019, Java SE 8 public updates will no longer be available for business, commercial or production use without a commercial license although it will remain free for general purpose computing usage.
Oracle previously released these older versions as free public updates. The Oracle Java license change kicks in for Java 11 and later. With these releases, Oracle now requires a commercial subscription for the use of the Oracle Java Runtime Environment.
What is the New Java SE Licensing Structure? Under this new model, customers will no longer purchase licenses upfront and pay annual support for Java SE. Instead, they will pay a monthly subscription fee under one to three-year terms for server or desktop licensing and support.
Oracle Java 7 and 8 contain a file ${java.home}/LICENSE
. For 1.7.0_80 and 1.8.0_152, the content is:
Please refer to http://java.com/license
After 6 HTTP redirects, that currently leads to https://www.oracle.com/downloads/licenses/binary-code-license.html, which describes "Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX."
${java.home}/LICENSE
in Oracle Java 1.8.0_221 says:
Please refer to https://java.com/bc_license
After 3 HTTP redirects, that currently leads to https://www.oracle.com/downloads/licenses/javase-license1.html, which describes "Oracle Technology Network License Agreement for Oracle Java SE."
${java.home}/LICENSE
in Oracle Java 1.8.0_251 says:
Please refer to https://java.com/otnlicense
Oracle and OpenJDK Java releases 9+ don't provide ${java.home}/LICENSE
.
All Java releases have a file ${java.home}/release
, which looks like this for Oracle Java 11:
BUILD_TYPE="commercial"
IMPLEMENTOR="Oracle Corporation"
...
and this for Ubuntu's openjdk-11-jre-headless package (version 11.0.4+11-1ubuntu2~18.04.3):
IMPLEMENTOR="Ubuntu"
...
There is no BUILD_TYPE
value in the case of the Ubuntu package.
Other results with downloads from java.net:
jre-8u221-linux-i586.tar.gz and jdk-8u251-linux-i586.tar.gz :
BUILD_TYPE="commercial"
jdk-9+181_linux-x64_ri.zip:
IMPLEMENTOR="N/A"
serverjre-9_linux-x64_bin.tar.gz (java -version
says build 9+181
):
BUILD_TYPE="commercial"
IMPLEMENTOR="Oracle Corporation"
openjdk-10+44_linux-x64_bin_ri.tar.gz:
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION_DATE="2018-03-20"
jdk-10_linux-x64_bin_ri.tar.gz (java -version
says build 10+44
):
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION_DATE="2018-03-20"
openjdk-11+28_linux-x64_bin.tar.gz:
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION_DATE="2018-09-25"
jdk-11.0.4_linux-x64_bin.tar.gz:
BUILD_TYPE="commercial"
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION_DATE="2019-07-16"
openjdk-12.0.2_linux-x64_bin.tar.gz:
IMPLEMENTOR="Oracle Corporation"
JAVA_VERSION_DATE="2019-07-16"
Oracle Java 7 and 8 installed on Ubuntu via the oracle-java7-installer and oracle-java8-installer packages also provide ${java.home}/release
, containing:
BUILD_TYPE="commercial"
Java 9+ distributions contain a ${java.home}/legal
directory. Examining ${java.home}/legal/java.base/LICENSE
:
legal/*/LICENSE
are identical)legal/*/LICENSE
are identical)Ubuntu's openjdk-11-jre-headless 11.0.4+11-1ubuntu2~18.04.3 provides no ${java.home}/legal/*/LICENSE
.
Strangely, it looks like "https://java.com/bc_license" in ${java.home}/LICENSE
is a good indication of an OTN-licensed JRE. I suppose it was a mistake that for Oracle releases after March 16, 2019, the URL in LICENSE
changed from "http://java.com/license" to "https://java.com/bc_license"; they should have changed it to "https://java.com/otnlicense". Their remedy was to make https://java.com/bc_license redirect to the OTN document.
A strong hint is when ${java.home}/legal/java.base/LICENSE
contains "Please refer to https://java.com/otnlicense".
A weaker hint is the combination of:
IMPLEMENTOR="Oracle Corporation"
,BUILD_TYPE="commercial"
, andJAVA_VERSION_DATE="2019-04-16"
or later.More robust answers welcome though!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With