Do I need to open my source code if I use OpenJDK as JVM?

The license for OpenJDK is not "GPL v2", it's "GPL v2 with the Classpath Exception". Quote:

As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library.


Do I need to open my source code if I use OpenJDK as JVM?

Absolutely not.

There are many commercial, closed-source Java applications out there that use OpenJDK-based JVMs. The "Classpath exception" that @Chris Lercher mentions specifically makes this legal.

Incidentally, the "Classpath exception" was invented by FSF's lawyers specifically to allow the GNU Classpath libraries (a cleanroom reimplementation of the Java SE libraries) to be used to run proprietary / closed source applications. Hence, the name ...

The only cases where you would need to worry are things like:

  • Closed source JVMs that make use of the OpenJDK code base in their implementation.
  • Closed source applications that contain modified copies of OpenJDK classes without including source code for the modifications.
  • Closed source applications that link to certain OpenJDK GPLv2 classes that are not marked as with the Classpath exception.

In OpenJDK 11, the last category seems to consist of a large number of "test" classes that are not included in an OpenJDK distro anyway, and internal classes that you shouldn't (and probably can't) link to in an application. These classes are easy to identify. Search for Java source files in the OpenJDK source tree that contain the word "GNU" and not the word "Classpath"

It is worth noting that a significant proportion of the OpenJDK Java code base is 3rd-party code with permissive open source licenses. Linking to those classes is permitted.

Bundling OpenJDK with closed-source is not a problem. The GPL permits you to distribute binaries for GPL software together with binaries for closed source software.