Wednesday, May 9, 2012

How to Change JDK used by Weblogic Server

Hi all,

Sometime it is required to switch JDK used by weblogic server for example from Sun to JRockit (which gives better performance). Another use case could be to switch from 32 to 64 bit JDK as well as latest supported JDK. To verify supported JDK version check Oracle FMW support matrix


In this post we will switch JDK from Sun to JRockit and i assume we are on Linux environment find same configuration file name with .CMD extension if you are on windows.

Installing new JDK:


First step is to install your desired JDK. Follow these steps to install

1. Download JRockit JDK from OTN

2. FTP the file to server and unzip it by running following command

$ unzip  jrockit_282V30318-01.zip

3. The file will be extracted with .bin extension, change the permission and make it executable.

$ chmod 755 jrockit-jdk1.6.0_29-R28.2.2-4.1.0-linux-x64.bin

4. Install JRockit to your desired location (in my example i have xserver running).

Follow the wizard to complete the installation. I installed JRockit on /u01/Oracle/jrockit-r28.2.2


$ ./jrockit-jdk1.6.0_29-R28.2.2-4.1.0-linux-x64.bin

Changing Weblogic Configuration to use new JDK

1. Shutdown all managed servers in Weblogic domain

2. Backup the following files
$MW_HOME/user_projects/domains/<domain  name>/bin/setDomainEnv.sh
$WL_HOME/common/bin/commEnv.sh

e.g.
$ cd  /u01/Oracle/Middleware/user_projects/domains/base_domain/bin
$ cp setDomainEnv.sh  setDomainEnv.sh.before_jdk_change

$ cd /u01/Oracle/Middleware/wlserver_10.3/common/bin
$ cp commEnv.sh  commEnv.sh.before_jdk_change

3. Edit setDomain.env file and find ${JAVA_HOME}
     Comment the JAVA_HOME entry


#JAVA_HOME="${JAVA_HOME}"
#export  JAVA_HOME


4. Add the following after this


# Added the following lines to change to JRockit JDK
JAVA_HOME="/u01/Oracle/jrockit-r28.2.2"
export  JAVA_HOME
JAVA_VENDOR="Oracle"
export JAVA_VENDOR



5. Search the following section in the file, specifically for "-Djrockit.optfile":


Note: This parameter usually gives warning of being obsolete
you will find


EXTRA_JAVA_PROPERTIES="-Dcommon.components.home=${COMMON_COMPONENTS_HOME}   -Djrf.version=11.1.1  
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger  
-Ddomain.home=${DOMAIN_HOME}  
-Djrockit.optfile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt  
-Doracle.server.config.dir=${ORACLE_DOMAIN_CONFIG_DIR}/servers/${SERVER_NAME}  
-Doracle.domain.config.dir=${ORACLE_DOMAIN_CONFIG_DIR} 
......"

remove the "-Djrockit.optfile" property:
-Djrockit.optfile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt

6. Save the file

7. Edit commEnv.sh file, find the following section

if [ -z "${JAVA_HOME}" -o -z "${JAVA_VENDOR}" ]; then


8. Add the following line after above section
JAVA_HOME="/u01/Oracle/jrockit-r28.2.2"
export JAVA_HOME
JAVA_VENDOR="Oracle"
export JAVA_VENDOR



9. Start Admin Server and confirm your changes by running following command

$  ps -ef | grep Admin

if you see something similar then your are good to start other managed servers
oracle   13927 13771  5 15:30 ?        00:03:58 /u01/Oracle/jrockit-r282.2/bin/java -jrockit -Xms2048m -Xmx2048m -Dweblogic.Name=AdminServer

Hope it help,
Zeeshan Baig