Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

enter image description here

like image 572
Luis Frediani Avatar asked Nov 25 '17 21:11

Luis Frediani


People also ask

What version of Java do I need to run GlassFish?

“GlassFish requires Java SE version 6. Your JDK is version 0” I'm trying to use Glassfish on a Mac running 10.15.6 Catalina. When I run the command, "GlassFish requires Java SE version 6. Your JDK is version 0" Numerous posts online said to add to the file "asenv.conf," a path to the JDK, such as

What version of JDK does Eclipse GlassFish support?

This release supports JDK 11. The latest stable release for Eclipse GlassFish 6.1. It is functionally complete and meets the compatibility requirements of the approved final version of the Jakarta EE 9.1 Specification. Downloads are provided for both Jakarta EE Platform 9.1 and Jakarta EE Web Profile 9.1.

Does GlassFish hard-code its reference to your JDK?

(This was for a Swing application, where the users only had Java 5 installed.) Apparently when Glassfish is installed it hard-codes its reference to your JDK location, so to fix this problem I ended up having to edit a file named asenv.bat.

Is GlassFish compatible with Jakarta EE 9?

Eclipse GlassFish 6.1 is targetted to be a Compatible Implementation of Jakarta EE 9.1. Note this release requires JDK 11. The final release is scheduled to coincide with the final release of Jakarta EE 9.1.


4 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

like image 183
Nirmal Sharma Avatar answered Oct 21 '22 23:10

Nirmal Sharma


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

like image 35
Thai Ha Avatar answered Oct 21 '22 23:10

Thai Ha


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?

like image 27
samneric Avatar answered Oct 21 '22 23:10

samneric


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

like image 1
Falchio Avatar answered Oct 22 '22 01:10

Falchio