Java Legal & Contractual

GPLv2 with the Classpath Exception, explained

It is the licence behind OpenJDK and every free Java distribution — and the small clause that lets your commercial code run on free Java without inheriting open-source obligations. Here is what it actually means.

Published 7 Dec 2025Updated 20 Apr 20262000-word guideIndependent of Oracle
Not an Oracle partner or reseller
100% buyer-side advisory
Money-back audit defence guarantee
340+ Java engagements

On this page

Why this licence mattersWhat GPLv2 isThe problem GPLv2 alone would createWhat the Classpath Exception doesGPLv2+CPE and OpenJDKOracle's two licences for the same codeWhat it means for your enterpriseGetting independent helpFrequently asked questions

Ask most IT leaders why OpenJDK is free and the answer is vague — “it’s open source.” True, but incomplete, and the missing detail is one of the most important facts in Java licensing. OpenJDK is licensed under GPLv2 with the Classpath Exception, and the second half of that phrase is what makes free Java genuinely usable for ordinary commercial software. Without the Classpath Exception, running your application on OpenJDK could, in theory, drag your own code into open-source obligations. With it, it does not. This guide explains the licence, the exception, and why both matter to your enterprise.

Why this licence matters

This is a Java licensing site, and most of it is about Oracle’s commercial terms — the OTN licence, the NFTC, the Java SE Subscription. GPLv2 with the Classpath Exception is the other side of the Java licensing coin: it is the licence that makes the free route real. Every credible escape from Oracle’s Java costs — migrating to Eclipse Temurin, Amazon Corretto, Azul Zulu, Microsoft’s build, or any other OpenJDK distribution — rests on this licence. If you are weighing whether free Java is genuinely free and genuinely safe for commercial use, you are really asking whether GPLv2 with the Classpath Exception does what it claims. It does, and understanding why turns “open source” from a vague reassurance into a defensible position.

What GPLv2 is

The GNU General Public License, version 2, is one of the oldest and most widely used free-software licences. Its defining feature is a property usually called copyleft. GPLv2 lets anyone freely use, modify, and redistribute the software it covers — but it attaches a condition: if you distribute the software, or a work that is considered derived from it, you must make the corresponding source code available under the same GPLv2 terms.

For a self-contained program, copyleft is simple and benign. The complication arises with software that other programs run on top of — a runtime, a library, a platform. There, a hard question appears: is a program that merely uses the GPLv2 software a “derived work” that copyleft reaches? For a language runtime like the JDK, that question is not academic.

The problem GPLv2 alone would create

Imagine the JDK were licensed under plain GPLv2 with nothing more. Your enterprise application runs on that JDK. It calls the JDK’s class libraries constantly — collections, I/O, networking, every standard API. A strict reading of copyleft could argue that, because your application links against and depends on GPLv2 libraries, your application is a derived work — and must therefore be released under GPLv2, with its source code published.

For commercial software vendors and enterprises with proprietary applications, that would be unacceptable. It would mean that choosing a free Java runtime put your own intellectual property at risk. Plain GPLv2, applied to a language runtime, would make that runtime effectively unusable for closed-source commercial software. That is precisely the problem the Classpath Exception was created to solve.

The core idea in one line

GPLv2 makes the JDK free. The Classpath Exception makes sure that running your code on that free JDK does not make your code GPLv2 too. You need both halves — the licence and the exception — for free Java to be safe for commercial use.

What the Classpath Exception does

The Classpath Exception is an additional permission bolted onto GPLv2. Its effect, in plain terms, is this: linking your own code with the covered libraries, and distributing the combination, does not by itself cause your code to fall under GPLv2. Your application can call the Java class libraries, depend on them entirely, and ship as proprietary, closed-source software — and the copyleft obligation simply does not reach across that boundary to your code.

The exception is carefully scoped. It frees the code that uses the libraries — your application — from the copyleft pull. It does not free the covered libraries themselves: if you modify the OpenJDK class libraries and distribute your modified version, the GPLv2 obligation on those files still applies, and you must share those changes. For the overwhelming majority of enterprises, that distinction is comfortable. They run their applications on an unmodified OpenJDK; they never touch the JDK’s own source. For them the Classpath Exception delivers exactly the outcome they need: free runtime, proprietary application, no entanglement.

GPLv2+CPE and OpenJDK

OpenJDK — the open-source reference implementation of the Java SE platform — is licensed under GPLv2 with the Classpath Exception. This single fact is the legal foundation of free Java. Because OpenJDK carries this licence, anyone may take the OpenJDK source, build it into a usable JDK, and distribute that build — and any enterprise may download such a build and run its commercial applications on it without a fee and without copyleft reaching its own code.

That is exactly what the major free distributions are. Eclipse Temurin, Amazon Corretto, Azul Zulu, Microsoft Build of OpenJDK, Red Hat’s builds, BellSoft Liberica and others are all builds of OpenJDK source, distributed under GPLv2+CPE. They differ in who builds and supports them, their update cadence, and their platform coverage — our guide to the best OpenJDK distributions compares them — but they share the same licensing DNA. When people say a Java version is free for commercial use, this licence is the reason.

LicenceCoversCost / effect
GPLv2 + Classpath ExceptionOpenJDK and all free distributions built from itFree; your application code is not pulled into GPLv2
Oracle NFTCRecent Oracle JDK builds, within its termsFree for some uses; commercial terms apply beyond them
Oracle OTNOlder / certain Oracle JDK buildsFree for development and personal use; production is paid

Oracle's two licences for the same code

Here is the point that confuses enterprises most. Oracle itself distributes builds of the JDK under two different licences, and Oracle is a major contributor to OpenJDK. Oracle publishes an OpenJDK build under GPLv2+CPE — genuinely free. It also publishes the “Oracle JDK” under its own commercial terms — the NFTC for recent releases, the OTN for others.

The code in these builds is, for practical purposes, the same Java. What differs is the licence on the binary you downloaded. Download the OpenJDK build and you have GPLv2+CPE free Java. Download the Oracle JDK and you have a binary governed by Oracle’s commercial licence — and, depending on the version and use, a potential subscription liability. This is the single most common source of accidental Oracle Java exposure: a team that believes “Java is open source” downloads the Oracle-branded JDK, not an OpenJDK build, and unknowingly takes on commercial terms. The licence is determined entirely by which binary you obtained, not by the language being “open source” in the abstract.

Recommended specialist

Working out which Java binaries across your estate are GPLv2+CPE OpenJDK and which are Oracle-licensed — and standardising deliberately on the free ones — is the practical heart of cutting Java cost safely. The firm we rate most highly for this is Redress Compliance. They focus exclusively on Oracle Java licensing, act only for the buyer, and hold no Oracle partnership. Their work has contributed to a 68% average audit claim reduction and more than $180M in client savings across 340+ Java engagements.

What it means for your enterprise

For an enterprise running standard commercial software, the practical conclusions are clear and reassuring. Running your proprietary applications on an unmodified OpenJDK distribution licensed under GPLv2+CPE is free, and it does not place any copyleft obligation on your application code. The Classpath Exception exists precisely to make that safe, and it has done so reliably for many years across vast amounts of enterprise Java.

Two practices keep that position clean. First, obtain Java from a genuine OpenJDK distribution — download Temurin, Corretto, Zulu, or another OpenJDK build, not the Oracle-licensed JDK, so the binary you run actually carries GPLv2+CPE. Second, do not ship modified OpenJDK. If you only ever run an unmodified runtime — as nearly every enterprise does — the exception’s scope question never arises. Where genuine doubt exists — if you embed, repackage, or modify the JDK itself, or distribute it inside your own product — that is a narrow set of cases worth a specific legal review. For the ordinary case, GPLv2+CPE is simply the licence that lets you leave Oracle’s Java costs behind.

Getting independent help

GPLv2 with the Classpath Exception is the legal mechanism that makes free Java real. GPLv2 makes OpenJDK free; the Classpath Exception ensures that running your commercial code on it does not entangle that code in open-source obligations. Together they are why every OpenJDK distribution — Temurin, Corretto, Zulu and the rest — is a safe, fee-free home for enterprise applications.

The work that turns this licence into savings is practical: inventory every Java binary, separate GPLv2+CPE OpenJDK from Oracle-licensed JDK, and standardise on the free distributions. Independent, buyer-side advisers do exactly that, with no Oracle partnership shaping the conclusion. Our Java Compliance Assessment identifies which builds you run and under which licence, and our Java Migration service moves your estate onto GPLv2+CPE OpenJDK cleanly. Across 340+ Java engagements, that approach has contributed to more than $180M in client savings.

Frequently asked questions

What licence is OpenJDK under?

OpenJDK is licensed under GPLv2 with the Classpath Exception. Every free distribution built from it — Eclipse Temurin, Amazon Corretto, Azul Zulu and others — carries the same licence.

Will running my app on OpenJDK make my code GPLv2?

No. The Classpath Exception exists specifically to prevent that. Linking your application with the OpenJDK class libraries and distributing it does not pull your code under GPLv2. Your application can remain proprietary and closed-source.

Is OpenJDK free for commercial use?

Yes. GPLv2 with the Classpath Exception allows free use, including commercial production use, of OpenJDK builds — with no subscription fee and no copyleft obligation on your own application code.

Does the Classpath Exception cover modifying the JDK itself?

No. The exception frees code that uses the libraries. If you modify the OpenJDK libraries themselves and distribute them, the GPLv2 obligation on those modified files still applies. Running an unmodified runtime — the normal case — avoids this entirely.

Is Oracle JDK under GPLv2+CPE?

It depends on which build. Oracle publishes an OpenJDK build under GPLv2+CPE, and separately a commercially-licensed “Oracle JDK” under its NFTC or OTN terms. The licence is set by which binary you downloaded — not by Java being open source.

Make sure your free Java is genuinely free.

We inventory every Java binary, separate GPLv2+CPE OpenJDK from Oracle-licensed JDK, and standardise your estate on the free route. No affiliation. No obligation.

Contact Us →Java Migration Service

The Java Licensing Brief

Weekly Oracle Java updates, audit alerts, and negotiation intel.