I've got GlassFish 2.1.1 installed. I have a 1.5 and a 1.6 JDK installed. Even though my JAVA_HOME variable is set to the 1.5 version (and both "java -version" and "javac -version" display 1.5), whenever I start my glassfish domain it always states at the top of the log that its using version 1.6. How can I override this?
Starting Domain domain2, please wait.
04-May-2012 08:38:47 com.sun.enterprise.admin.servermgmt.launch.ASLauncher buildCommand
INFO:
C:/Dev/jdk/1.6/1.6.0_19\bin\java
Required JDK Versions Eclipse GlassFish Server Release 5.1 requires Oracle JDK 8 Update 144 or later.
This variable can be found in the . bash_profile file of the user which is used to start GlassFish. Run “echo $JAVA_HOME” to see its current value.
Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.
Here you can find how to set path to JDK for Glassfish: http://www.devdaily.com/blog/post/java/fixing-glassfish-jdk-path-problem-solved
Check
glassfish\config\asenv.bat
where java path is configured
REM set AS_JAVA=C:\Program Files\Java\jdk1.6.0_04\jre/..
set AS_JAVA=C:\Program Files\Java\jdk1.5.0_16
Adding the actual content from dbf's link in order to keep the solution within stackoverflow.
It turns out that when I first installed Glassfish on my Windows system I had JDK 6 installed, and recently I had to downgrade to JDK 5 to compile some code for another project.
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. In short, I edited this file:
C:\glassfish\config\asenv.bat:
and I commented out the reference to JDK 6 and added a new reference to JDK 5, like this:
REM set AS_JAVA=C:\Program Files\Java\jdk1.6.0_04\jre/..
set AS_JAVA=C:\Program Files\Java\jdk1.5.0_16
Although the path doesn't appear to be case sensitive, I've spent hours debugging an issue around JMS Destination object not found due to my replacement path's case being incorrect.
I'm working on a Mac, OSX 10.9. I recently had to update my JDK to 1.7 for some VPN software. The application I'm working runs on JDK 1.6, so a GlassFish had to run with JDK 1.6. It took a minute to iron this out, but here's how it went for me. I work with the NetBeans IDE by the way.
My GlssFish configuration file
/Applications/NetBeans/glassfish-3.1.2.2/glassfish/config/asenv.conf
Path to JDK 1.6
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
I added the following line to the bottom of my asenv.conf
file
AS_JAVA=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
Had the same problem in my IntelliJ 17 after adding fresh glassfish 4.1.
I had set my JAVA_HOME
environment variable as follow:
echo %JAVA_HOME%
C:\Java\jdk1.8.0_121\
Then opened %GLASSFISH_HOME%\glassfish\config\asenv.bat
And just added and the end of the file:
set AS_JAVA=%JAVA_HOME%
Then Glassfish started without problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With