GlassFish requires Java SE version 6. Your JDK is version 0 (Mac)

Viewed 11321

I'm doing a project in IntelliJ with GlassFish and it throws this error:

GlassFish requires Java SE version 6. Your JDK is version 0.

I ran the glassfish4/bin/asadmin start-domain command in a terminal but still get the same error.

I do have Java SE installed, SDK version 8u152 (I checked on Java Panel). Also, I don't know why it searches for jdk 9.

enter image description here

enter image description here

5 Answers

For me java home was good, the only issue was that the version was not matching up.

Open “glassfish -> config -> asenv.conf”. Add the line AS_JAVA=PATH_TO_YOUR_JDK_DIRECTORY

The only stuff needs to be kept in mind is AS_JAVA=PATH_TO_YOUR_JDK_DIRECTORY should exactly match with the jdk version you mentioned in your intellij.

Now ->

C:\Program Files\Java\jdk1.8.0_40 is mentioned in intellij... file-> SDK's set AS_JAVA=C:\Program Files\Java\jdk1.8.0_40 is mentioned in glassfish -> config -> asenv.conf

Which me, open asenv.conf in PATH_TO_YOUR_GLASSFISH/glassfish/config folder, go to end of lines and add set AS_JAVA=/PATH_TO_YOUR_JAVA/Java/JavaVirtualMachines/jdk-YOUR-VERSION.jdk

I tried all these approaches and none worked for me.

All answers talk about going to folder PATH_TO_YOUR_GLASSFISH/glassfish/config and then editing asenv.conf.

Editing that file didn't have have any effect.

I did go to that folder but ended up editing asenv.bat.

I literally added this to the end: set AS_JAVA=../../../../Program Files/Java/jdk1.8.0_261

The generic instruction would be: set AS_JAVA=PATH_TO_YOUR_JDK

Note: the asenv.conf file has quotes around values, asenv.bat does not.

I finally tracked the answer down from this question:

How do I specify the JDK for a GlassFish domain?

Go to folder '..\GlassFish-4.1.2\glassfish4\glassfish\config'. Open in Notepad: asenv.bat Add in end row: set AS_JAVA=....\Java\jdk1.8.0_291

Related