Not all modules can be enabled - e.g. org-netbeans-modules-nbjavac.jar

Error in NetBeans with Module org.netbeans.modules.nbjavac

I am getting an error with NetBeans not enabling the module org.netbeans.modules.nbjavac when it is located at C:\Users\...\AppData\Roaming\NetBeans\11.2\modules\org-netbeans-modules-nbjavac.jar.

I am aware of popular problem with multiple modules noted as not possible to be enabled due to wrong JDK path. My path to JDK seems to be about right, as shown by the following code block:

netbeans_jdkhome="D:\Program Files\Java\jdk1.8.0_231"

However if I comment it out (as suggested in some solutions) to enable hints, the project does not start because of multiple errors on TomEE, as shown by the following code block:

WARNING: An illegal reflective access operation has occurred 
WARNING: Illegal reflective access by org.apache.openejb.loader.TomcatClassPath$3 (file:/D:/Programming/apache-tomee-webprofile-7.0.2/lib/openejb-loader-7.0.2.jar) to method java.net.URLClassLoader.addURL(java.net.URL) 
WARNING: Please consider reporting this to the maintainers of org.apache.openejb.loader.TomcatClassPath$3 
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 
WARNING: All illegal access operations will be denied in a future release 
06-Jan-2020 06:24:23.213 INFO [main] org.apache.openejb.util.OptionsLog.info Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator' 
06-Jan-2020 06:24:23.230 SEVERE [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Catalina.start org.apache.catalina.LifecycleException: Failed to initialize component [StandardServer[8005]] 
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112) 
at org.apache.catalina.startup.Catalina.load(Catalina.java:606) 
at org.apache.catalina.startup.Catalina.load(Catalina.java:629) 
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.base/java.lang.reflect.Method.invoke(Method.java:567) 
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:311) 
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:494)

06-Jan-2020 06:24:23.231 WARNING [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Calling stop() on failed component [StandardServer[8005]] to trigger clean-up did not complete. org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[8005]] 
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:238) 
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:264) 
at org.apache.catalina.startup.Catalina.start(Catalina.java:659) 
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.base/java.lang.reflect.Method.invoke(Method.java:567) 
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) 
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) 
Caused by: org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_stop]) for component [StandardService[Catalina]] in state [INITIALIZED] 
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:402) 
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:213) 
at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:812) 
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226) 
... 8 more

Is there a way to use my JDK and use hints?

One possible solution to this issue is to add the netbeans_jdkhome property to the netbeans.conf file located in the NetBeans installation folder.

  1. First, locate the netbeans.conf file. It is usually located in the etc folder of the NetBeans installation directory. For example, C:\Program Files\NetBeans\etc\netbeans.conf.

  2. Open the netbeans.conf file in a text editor.

  3. Look for the line that starts with netbeans_default_options. It may look something like this:

    netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true"
    
  4. Add the netbeans_jdkhome property after the netbeans_default_options line. For example:

    netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true"
    netbeans_jdkhome="D:\Program Files\Java\jdk1.8.0_231"
    
  5. Save the netbeans.conf file and restart NetBeans.

  6. Try to enable the org.netbeans.modules.nbjavac module again. If successful, you should be able to use your JDK and the hints feature without any issues.