What’s "nb-javac" in Apache NetBeans?
Not long after you start up Apache NetBeans (incubating) 9.0 on top of JDK 8, after accepting the license agreement and handling import settings, you’re confronted with this dialog:
What does that mean? And why, when you start up Apache NetBeans (incubating) 9.0 on top of JDK 9 or above, do you see the following, instead:
|The above appears in a balloon popup in the bottom right the first time you start up Apache NetBeans (incubating) 9.0 on JDK 9 or above. If you miss out on seeing or responding to the message, go to Window | IDE Tools | Notifications anytime afterwards and you’ll have another opportunity to install it:|
Let’s start by looking at the question, what is "nb-javac"? Well, "nb-javac", which is a patched version of "javac", i.e., the Java compiler, has long been part of NetBeans, providing a highly tuned Java compiler specifically for the Java editor in NetBeans, and wasn’t part of the donation of NetBeans to Apache since, of course, the Java compiler (or a fork thereof) cannot be part of the donation. That’s because Oracle is not donating Java to Apache, instead, it is donating NetBeans. The Java compiler belongs to the JDK which is licensed to Oracle.
Separate from Oracle’s obvious understandable unwillingness to donate a Java compiler fork to Apache, or anyone else, Apache would have a problem with a fork of the Java compiler being distributed from Apache since the Java compiler is LGPL licensed.
In short, neither Oracle nor Apache want the Java compiler to be part of NetBeans in Apache. Yet, NetBeans gains a lot from the patched Java compiler, as explained below:
Also see this reference for details on the situation:
However, using model APIs added in JDK 9, Apache NetBeans can make use of the Java compiler directly from the JDK, as explained here:
So, as can be seen, from Apache NetBeans running on JDK 9 and onwards, you have a choice: either use the Java compiler from the JDK, which means you’re not benefiting from a number of enhancements especially added for NetBeans over many years in the patched Java compiler, or you need to explicitly add the patched Java compiler, since it is provided by Oracle and its licensing is such that you need to take responsibility for installing it yourself. On the other hand, if you’re using Apache NetBeans with JDK 8, the choice is simpler, i.e., you need to install nb-javac, otherwise you will not be able to use Java in Apache NetBeans.
It’s not an ideal situation. On the other hand, if someone has a better solution, please feel free to propose that solution and also consider providing a pull request too!