user233923
user233923

Reputation: 51

How can I solve a Netbeans 12.0 IllegalAccessError?

I just installed Netbeans 12.0. When I started my first project I got an unexpected error message just after creating a new java class. Any suggestions on how I can handle it?

This is the message:

java.lang.IllegalAccessError: superclass access check failed: class org.netbeans.lib.nbjavac.services.CancelAbort (in unnamed module @0x439ece0a) cannot access class com.sun.tools.javac.util.Abort (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x439ece0a

And this is my System Info:

Product Version = Apache NetBeans IDE 12.0
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 16.0.1; Java HotSpot(TM) 64-Bit Server VM 16.0.1+9-24; Oracle Corporation
Runtime:Java(TM) SE Runtime Environment 16.0.1+9-24
Java Home:c:\program files\java\jdk-16.0.1
System Locale Encoding: pt_BR (nb); Cp1252
Home Directory: C:\Users\User
Current Directory: C:\Program Files\NetBeans-12.0
User Directory: C:\Users\User\AppData\Roaming\NetBeans\12.0
Cache Directory :C:\Users\User\AppData\Local\NetBeans\Cache\12.0

Upvotes: 5

Views: 5454

Answers (2)

skomisa
skomisa

Reputation: 17363

You are using JDK 16, which is unsupported on NetBeans 12.0. From the release documentation for NetBeans 12.0:

Apache NetBeans 12.0 runs on the JDK LTS releases 8 and 11, as well as on JDK 14, i.e., the current JDK release at the time of this NetBeans release.

You have two options to resolve this:

  • Stay with NetBeans 12.0, but use the most recent JDK which it supports, JDK 14.
  • Install a more recent version of NetBeans and use the most recent JDK which that version supports. For example, use NetBeans 12.4 with JDK 16.

The second option is preferable because you will get bug fixes for NetBeans, and you can also use a more recent JDK.

FYI, based on the NetBeans release documentation, here is a summary of the JDK versions you can use with all recent versions of NetBeans:

NetBeans 11.0: JDK 8, JDK 11, JDK 12

NetBeans 11.1: JDK 8, JDK 11, JDK 12

NetBeans 11.2: JDK 8, JDK 11, JDK 13

NetBeans 11.3: JDK 8, JDK 11, JDK 14

NetBeans 12.0: JDK 8, JDK 11, JDK 14

NetBeans 12.1: JDK 8, JDK 11, JDK 14

NetBeans 12.2: JDK 8, JDK 11, JDK 15

NetBeans 12.3: JDK 8, JDK 11, JDK 15

NetBeans 12.4: JDK 8, JDK 11, JDK 16

NetBeans 12.5: JDK 8, JDK 11, JDK 17 (n.b. "experimental support")

NetBeans 12.6 is less straightforward: Requires JDK 11+, and officially supports running on JDK 11 and JDK 17, but can be run on JDK 8, with some features disabled, if built from source using JDK 8.

More generally:

  • Version 12.x of NetBeans (excluding 12.6 as noted above) supports exactly three JDKs: JDK8, JDK 11 and the latest JDK which is current at the time of the NetBeans release.
  • JDKs which come out after the release date of any given version of NetBeans are unsupported.

Upvotes: 6

Vidhi Sharma
Vidhi Sharma

Reputation: 13

I had the same error. I have netbeans 12.0 and jdk 16 but I was able to solve this by updating. In netbeans, Go to Help-> About-> and then see if there is any update...let that happen and this error will go.

Upvotes: 0

Related Questions