How to modify the version of Java used for GlassFish 126.96.36.199
September 10, 2012 2 Comments
Environment: GlassFish 188.8.131.52 OSE Web Profile, Oracle Linux 6.3, Java 7 Update 7.
Whenever you upgrade your Java installation or install a new version, you have to make sure that your GlassFish installation is using the new version.
1) Download and install the new Java JDK
New versions of Java can be found here. For GlassFish, you need to download the JDK (so not JRE), and you can use both Java 6 or Java 7.
For example, I downloaded and installed JDK 7 Update 7 to /u01/app/jdk1.7.0_07 and I created a symbolic link “java7” to it:
$ /u01/app/java>tar -zxf jdk-7u7-linux-x64.tar.gz $ /u01/app/java>ln -sf jdk1.7.0_07 java7 $ /u01/app/java>ls -la total 93904 drwxr-xr-x 4 oracle oinstall 4096 Sep 10 15:16 . drwxr-xr-x 7 oracle oinstall 4096 Feb 17 2012 .. lrwxrwxrwx 1 oracle oinstall 11 Feb 7 2012 java6 -> jdk1.6.0_30 lrwxrwxrwx 1 oracle oinstall 11 Sep 10 15:16 java7 -> jdk1.7.0_07 drwxr-xr-x 10 oracle oinstall 4096 Feb 3 2012 jdk1.6.0_30 drwxr-xr-x 8 oracle oinstall 4096 Aug 29 03:12 jdk1.7.0_07
2) Modify the GlassFish domain config file and JAVA_HOME environment variable
Next, you need to modify the AS_JAVA variable in the GlassFish config file “asenv.conf”. In my case, this file was stored in the folder /u01/app/glassfish/glassfish/config. I changed it as follows:
You also need to modify the environment variable JAVA_HOME. 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. After the changes, log out and log in again (or run .bash_profile) to reset it.
3) Restart the GlassFish domain server
Restart the GlassFish domain server and any other server instances you might have.
/u01/app/glassfish/bin/asadmin stop-domain domain1
/u01/app/glassfish/bin/asadmin start-domain domain1