Search code examples
javaservletsnetbeans

What version of Java supports GlassFish 7.0.0 on a Mac?


I have NetBeans 17 and the highest GlassFish version is 7.0.0. I have Java JDK 19 installed but GlassFish tells me it is not compatible with JDK 19.

What version of JDK is suitable for GlassFish 7.0.0 or lower?


Solution

  • I can reproduce your problem. I just tried to start GlassFish 7 on NetBeans 17 using JDK 20, and NetBeans wouldn't let me do that. But when I selected JDK 17 instead it worked fine. So to resolve this:

    • Use Tools > Java Platforms... > Add Platform to add JDK 17 as a platform in NetBeans.

    • Download and install the latest release of GlassFish 7: version 7.0.4.

    • When you try to start GlassFish 7.0.4 as a server within NetBeans it will fail ("GlassFish server could not be started..."), but NetBeans should then invite you to select an alternative platform to use instead:

      Select JDK

    • Note that if JDK 19 is your only platform in NetBeans you won't be given the option to select an alternative platform, and you won't be able to resolve the issue.

    • Just select JDK 17 as your Java Platform and click OK and everything should work. I am running GlassFish 7 on JDK 17 within NetBeans 17 which is using JDK 20 and it is working. Using JDK 18 instead also worked for me.

    See the Eclipse GlassFish download page for details on the latest releases and their JDK requirements. It looks like all releases of GlassFish 7 formally support the use of JDK19.

    Notes:

    • Don't let NetBeans download GlassFish 7.0.0 for you; that is only going to lead to problems. Instead, create an empty directory (e.g. C:/GlassFish704), and then download and install the latest release, GlassFish 7.0.4, into that directory yourself. Then, when you add GlassFish 7 as a server, navigate to the root directory of that GlassFish 7.0.4 installation. In my case (on Windows) that path was C:/GlassFish704/glassfish-7.0.4/glassfish7
    • Do not use GlassFish 7.0.0 because there is an unrelated problem with the Admin Console: "GlassFish Server Administration Console (http://localhost:4848) cannot be loaded.". You will see a ResolveError in the GlassFish log, and you won't be able to open the Admin Console, typically from http://localhost:4848/common/index.jsf.
    • I think a minor bug in NetBeans caused you to hit this issue, since NetBeans does officially support the use of JDK 19. It seems that there is a needless hard coded constraint preventing you from using JDK 19 with GlassFish 7.x.x.