Issue
when I click on run, it displays this message in a dialog box.
' Glassfish server could not be started with JDK 16. Please select another Java SE platform.
And then it displays this error
Deployment error: Could not find Java SE Development Kit to start GlassFish Server See the server log for details.
Is it a issue with glassfish version or jdk version? how can I fix this issue? any idea
Solution
You asked: "Is it a issue with glassfish version or jdk version?" - It's an issue with the combination of the GlassFish version and the JDK version that you are trying to use. For example, see here.
"GlassFish 6.2.5 ... officially supports JDK 11 ... runs on JDK 17 and JDK 18ea."
"GlassFish 6.1.0 ... supports JDK 11."
"GlassFish 6.0.0 ... only supports JDK 8."
And so on.
Going farther back in time:
"GlassFish 5.1 requires Oracle JDK 8 Update 144 or later."
Generally speaking, unless you have a good reason not to do so, you should try to use a Java LTS (long-term support) release. You can see a list of recent and older JDK releases, which shows which releases are LTS and which are not. LTS releases:
- 8
- 11
- 17
(But that does not mean GlassFish will not run on other versions. Follow the GlassFish release guidelines.)
You also tagged your question as a NetBeans question.
If you need to change the version of Java you are using in NetBeans, you can go to Tools > Java platforms > Add platform. But again, you may hit limitations where certain versions of NetBeans are not able to support certain versions of the Java JDK - so you need to check the NetBeans release guidelines for that.
For example for NetBeans 14:
"The Apache NetBeans 14 binary releases require JDK 11+, and officially support running on JDK 11 and JDK 17."
And going back to NetBeans 9:
"The main goals for this release are ... Java 9 and Java 10 Support."
Answered By - andrewJames
Answer Checked By - Senaida (JavaFixing Volunteer)