You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Humphrey Clerx <hc...@gmail.com> on 2021/06/02 13:30:47 UTC

Cannot use JDK 8 specific classes when compiling

I've updated from version 12.1 to 12.4 and am experiencing the following
problem:

I'm running NetBeans under Windows 10, with JDK 11 as the default Java
Platform (set in netbeans.conf) I'm using AdoptOpenJDK 11 (11.0.11+9).

Since my RCP project still requires JDK 8 as a runtime, I've added a Java
Platform in NetBeans 12.4, defined as JDK 1.8 and have set it to point to
the installed AdoptOpenJDK version for Java 8 (8u292-b10).

All of these settings were identical to the settings when using NetBeans
12.1.

When I compile/build my RCP project all works fine with NetBeans 12.1, but
in NetBeans 12.4 I get the following error. This happens both with nb-javac
installed and with nb-javac uninstalled.

During build:
Ignoring source, target and bootclasspath as release has been set.

Failure in build:
error: package sun.awt does not exist.

This happens because one of our classes
uses sun.awt.AppContext.getAppContext() to install our own RepaintManager
(to detect EDT violations).

I guess the reason is that in NetBeans 12.1 the actual java compiler used
to build the project is the one set as the Java Platform for the project
(8u292), but in NetBeans 12.4 the JDK 11 compiler is used with some kind of
"--release" flag to indicate that it should compile for Java 8. However,
this doesn't work when the application uses classes that are (no longer)
present in Java 11 (or above).

How can I change (if any) settings in NetBeans 12.4 to allow the build to
succeed, as is possible with NetBeans 12.1?

Greets,
    Humphrey.

-- 
In the mountains of truth, you never climb in vain - Nietzsche
#-------------------------------------------------------------
 \_O
,__/>
  <"
   '

Re: Cannot use JDK 8 specific classes when compiling

Posted by Juan Algaba <ja...@colef.mx>.
Is your project using Ant, Maven or Gradle?

On Wed, Jun 2, 2021 at 6:28 AM Humphrey Clerx <hc...@gmail.com> wrote:
>
> I've updated from version 12.1 to 12.4 and am experiencing the following problem:
>
> I'm running NetBeans under Windows 10, with JDK 11 as the default Java Platform (set in netbeans.conf) I'm using AdoptOpenJDK 11 (11.0.11+9).
>
> Since my RCP project still requires JDK 8 as a runtime, I've added a Java Platform in NetBeans 12.4, defined as JDK 1.8 and have set it to point to the installed AdoptOpenJDK version for Java 8 (8u292-b10).
>
> All of these settings were identical to the settings when using NetBeans 12.1.
>
> When I compile/build my RCP project all works fine with NetBeans 12.1, but in NetBeans 12.4 I get the following error. This happens both with nb-javac installed and with nb-javac uninstalled.
>
> During build:
> Ignoring source, target and bootclasspath as release has been set.
>
> Failure in build:
> error: package sun.awt does not exist.
>
> This happens because one of our classes uses sun.awt.AppContext.getAppContext() to install our own RepaintManager (to detect EDT violations).
>
> I guess the reason is that in NetBeans 12.1 the actual java compiler used to build the project is the one set as the Java Platform for the project (8u292), but in NetBeans 12.4 the JDK 11 compiler is used with some kind of "--release" flag to indicate that it should compile for Java 8. However, this doesn't work when the application uses classes that are (no longer) present in Java 11 (or above).
>
> How can I change (if any) settings in NetBeans 12.4 to allow the build to succeed, as is possible with NetBeans 12.1?
>
> Greets,
>     Humphrey.
>
> --
> In the mountains of truth, you never climb in vain - Nietzsche
> #-------------------------------------------------------------
>  \_O
> ,__/>
>   <"
>    '



-- 

-Juan Algaba

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists