3

I am developing a GUI Java-based application using swing and am thinking of using the MIT license, though when reading the licenses stated in the components of java swing I see that they are licensed under the GNU General Public Licensed version 2. From what I understand from reading about these licenses is that I cannot use a permissive license like MIT if I'm using code under the GNU license.

A similar question has been asked here: https://stackoverflow.com/questions/3111455/releasing-code-containing-java-swing-what-license The answer that they received is that it is possible to use any license that they want provided they only use swing library and not actually use or modify the source code.

From what I understood, GNU license is a copyleft license meaning that usage of the code forces the developer to use the same license.

Why then is it possible to use the MIT license when using the swing library?

2 Answers 2

2

Whenever you form and distribute a derivative of a GPL work, you must license that new derivative, as a whole, under the GPL.

Your code, in isolation, can be under the MIT license, but when it is combined and distributed with GPL-licensed code, that combination (probably) forms a derivative work which must be licensed as a whole under the GPL.

Note that the character sequence import javax.swing.* is not linking against a GPL'd library; indeed, many occurrences of that particular statement even predate the availability of a GPL-licensed Swing library. However, the distribution of such an import statement (and associated classes) alongside a copy of a GPL-licensed implementation of those namespaced classes probably does constitute distribution of a derivative.

Note the OpenJDK in particular is licensed with a classpath exception, which allows linking together independent modules to form an executable without licensing the whole work under the GPL:

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.

So, with the classpath exception, you need not license your resulting executable under the GPL, but must otherwise respect the source-sharing requirements of the modules that are licensed under the GPL.

0

The general consensus is the Stack Overflow answer you have linked to is incorrect; linking to a library creates a derivative work and therefore the GPL applies to the combined work. You can see some arguments in favour of this view here. Unsurprisingly, this is also the view of the FSF.

For the opposing view, see this question.

1
  • The linked question mentions the GPL in the context of OpenJDK, which includes a classpath exception in its terms (which in my very limited Java experience makes it function kind of like the LGPL). Does that change the substance of this answer?
    – apsillers
    Commented Sep 28, 2021 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.