简体   繁体   中英

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

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.

在此处输入图像描述

在此处输入图像描述

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

其中我,在PATH_TO_YOUR_GLASSFISH/glassfish/config文件夹中打开asenv.conf ,转到行尾并添加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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM