8

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

Bryan
  • 2,870
  • 24
  • 39
  • 44
Luis Frediani
  • 113
  • 1
  • 2
  • 7
  • 3
    Please do not post images of things that could simply have been posted as text. – Mark Rotteveel Nov 25 '17 at 22:01
  • 2
    You project default SDK is set to Java9. That is why intelliJ starts java command line along with JDK9 path. – Naman Nov 26 '17 at 12:11
  • so, how was the issue solved @Luis Frediani?? – Aashish Feb 11 '19 at 16:27
  • I suspect you are using software that is so old that it does not know about the change in how later versions of Java report their version number. I suggest upgrading to a later version of Glassfish or downgrading your Java to an older version. You may have multiple JVMs installed as well and are unaware of which is being used. – Basil Bourque Feb 12 '19 at 07:54

5 Answers5

3

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

Thai Ha
  • 1,331
  • 14
  • 21
2

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

1

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?

samneric
  • 3,038
  • 2
  • 28
  • 31
1

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

Falchio
  • 174
  • 1
  • 14
0

In my case, the issue was completely unrelated to IntelliJ setup and JAVA_HOME was pointing to correct path (version 1.8).

Despite that, runtime of java version 9 was actually used, so I uninstalled JRE 9. Left JDK9, since removing the runtime was enough as a quick fix.