'Why do I get IllegalStateException: Missing hosting module org.netbeans.libs.javacimpl when upgrade to Netbeans 13?

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?



Solution 1:[1]

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/[email protected]/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.

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OndroMih
Solution 2 abbas