4

After I upgraded Netbeans from 12.6 to 13, Netbeans doesn't start. When I start it from the command line, I got the following message:

java.lang.IllegalStateException: Missing hosting module org.netbeans.libs.javacimpl for fragment org.netbeans.modules.nbjavac.impl
    at org.netbeans.ModuleManager.refineClassLoader(ModuleManager.java:909)
    at org.netbeans.StandardModule.classLoaderUp(StandardModule.java:527)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1330)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1254)
    at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
    at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
    at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:298)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
    at org.netbeans.core.startup.Main.start(Main.java:282)
    at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
    at java.base/java.lang.Thread.run(Thread.java:829)

What's the reason? How can I fix it?

skomisa
  • 16,436
  • 7
  • 61
  • 102
OndroMih
  • 7,280
  • 1
  • 26
  • 44

2 Answers2

14

This is caused by old nb-javac (Netbeans Java Compiler) modules installed in an older Netbeans version, which are incompatible with nb-javac, which is now bundled in Netbeans.

It's necessary to remove those old modules. You can find them in the Netbeans user directory. On Linux this is for example in ~/.netbeans or in ~/snap/netbeans/current, if installed as a Snap package. Those nb-javac files are in the modules directory in that directory (e.g. ~/.netbeans/modules) and include nbjavac in the name, e.g. org-netbeans-modules-nbjavac-api.jar. Delete all such files that include nbjavac. Then start Netbeans again, all should work now.

This problem was reported for a development version of Netbeans 13 on the developers' mailing list: https://www.mail-archive.com/dev@netbeans.apache.org/msg09777.html. There are original instructions that helped me to fix this issue. I wasn't using any development build of Netbeans, I just upgraded from the regular version 12.6 to the version 13 of Netbeans. In Netbeans 12.6, I installed the nb-javac plugin, which probably brought these incompatible modules that needed to be removed.

OndroMih
  • 7,280
  • 1
  • 26
  • 44
  • Interesting. I just installed the release version of NB13 using JDK 17 on Windows 10, and I didn't get your problem. Is that possibly because I didn't import my 12.6 settings? If not, any idea why you got the problem but I didn't? – skomisa Mar 08 '22 at 07:14
  • Yes, it's because you didn't import 12.6. This only happens when Netbeans 13 imports configuration from an oledr installation and only if you installed the nb-javac plugin in the older installatoin. Before NB 13, nb-javac was distributed as a separate plugin and had to be installed manually, although most people did it because NB encouraged to do so after started. In NB 13, nb-javac is installed by default but conflicts with the plugin installed earlier. The old plugin has to be deleted to avoid the conflict. – OndroMih Mar 08 '22 at 11:52
  • OK. I deleted my cache and user directory for NB 13, and NB 13 itself, and then reinstalled NB13. I still didn't get your problem, even though I was importing from 12.6. I installed NB 13 from the zip rather than using an installer - is that possibly relevant? (An unrelated issue was that NB 13 made JDK 8 the default platform, even though it doesn't support it by default, and my default platform on 12.6 was JDK 17.) – skomisa Mar 08 '22 at 19:29
  • @skomisa, did you have nb-javac plugin files in the `modules` directory in your netbeans configuration directory (e.g. in ~/.netbeans/12.6/modules) ? I had these files there : org-netbeans-modules-nbjavac-api.jar,org-netbeans-modules-nbjavac-impl.jar, and org-netbeans-modules-nbjavac.jar. They got copied to the Netbeans 13 configuration and only when I deleted them I could start Netbeans 13. Previously I installed the nb-javac plugin into Netbeans 12.6, which isn't necessary with NB 13 anymore. – OndroMih Mar 15 '22 at 17:28
  • If you want to reproduce it, I think it's enough to start Netbeans 12.6, install the nb-javac plugin and then import Netbeans 12.6 into Netbeans 13. – OndroMih Mar 15 '22 at 17:29
  • 2
    On macOS, remove `~/Library/Application\ Support/NetBeans/13/modules/*` – Hank Apr 06 '22 at 14:21
0

People who are struggling on macOS, same answer as OndroMih but these directories

/Users/<your_user>/Library/Caches/NetBeans
/Users/<your_user>/Library/Application Support/NetBeans
abbas
  • 6,453
  • 2
  • 40
  • 36