Quantcast
Channel: The Middleware Shop » Liberty Profile
Viewing all articles
Browse latest Browse all 13

Changing the JAVA JRE for Liberty Profile

$
0
0

This guide explains How to install the IBM SDK or JRE using the public downloads.

It is possible to acquire the IBM SDK from the following URL, though you will need to register before downloading.

http://www.ibm.com/developerworks/java/jdk/linux/download.html

 

  • I have chosen to downloaded the 64 Bit version for the IBM 8 SDK/JRE

Note: It all depends on your requirements i.e. the application requirements to decide what SDK is required. In this example, I have used the IBM 8 SDK/JRE to demonstrate that Liberty can run in IBM 8 JRE

 

  • I was then prompted to register with IBM before I can continue.

 

 

 

  • Once I located the actual download page, I selected all the SDK options for example JDK and JRE and samples just in case I need them at another stage.

For Liberty we would only actually require the JRE to replace the standard default OpenJDK on CentOS for example.

In this example we will only install the IBM 8 JRE the file is:

ibm-java-x86_64-jre-8.0-2.0.bin

 

To do this we follow these steps:

Copy the JRE download to an appropriate folder for example:

/var/apps/installs/IBMSDK8

Modify to be able to run the bin file:

chmod 755 ibm-java-x86_64-jre-8.0-2.0.bin
  • Select the default options

Result:

Preparing to install…
Extracting the JRE from the installer archive…

Unpacking the JRE…

Extracting the installation resources from the installer archive…

Configuring the installer for this system’s environment…

Launching installer…

Graphical installers are not supported by the VM. The console mode will be used instead…

===============================================================================

Choose Locale…

—————-

1- Bahasa Indonesia

2- Català

3- Deutsch

->4- English

5- Español

6- Français

7- Italiano

8- Português

CHOOSE LOCALE BY NUMBER:

===============================================================================

IBM® 64-bit Runtime Environment for Linux®, v8.0 (created with InstallAnywhere)

——————————————————————————-

Preparing CONSOLE Mode Installation…

===============================================================================

International License Agreement for Non-Warranted Programs

Part 1 – General Terms

BY DOWNLOADING, INSTALLING, COPYING, ACCESSING, CLICKING ON AN

“ACCEPT” BUTTON, OR OTHERWISE USING THE PROGRAM, LICENSEE AGREES TO

THE TERMS OF THIS AGREEMENT. IF YOU ARE ACCEPTING THESE TERMS ON

BEHALF OF LICENSEE, YOU REPRESENT AND WARRANT THAT YOU HAVE FULL

AUTHORITY TO BIND LICENSEE TO THESE TERMS. IF YOU DO NOT AGREE TO

THESE TERMS,

* DO NOT DOWNLOAD, INSTALL, COPY, ACCESS, CLICK ON AN “ACCEPT” BUTTON,

OR USE THE PROGRAM; AND

* PROMPTLY RETURN THE UNUSED MEDIA AND DOCUMENTATION TO THE PARTY FROM

WHOM IT WAS OBTAINED FOR A REFUND OF THE AMOUNT PAID. IF THE PROGRAM

WAS DOWNLOADED, DESTROY ALL COPIES OF THE PROGRAM.

1. Definitions

Press Enter to continue viewing the license agreement, or enter “1” to

accept the agreement, “2” to decline it, “3” to print it, or “99” to go back

to the previous screen.: 1

===============================================================================

Introduction

————

InstallAnywhere will guide you through the installation of IBM® 64-bit Runtime

Environment for Linux®, v8.0.

It is strongly recommended that you quit all programs before continuing with

this installation.

Respond to each prompt to proceed to the next step in the installation. If you

want to change something on a previous step, type ‘back’.

You may cancel this installation at any time by typing ‘quit’.

PRESS <ENTER> TO CONTINUE:

===============================================================================

Choose Install Folder

———————

Where would you like to install?

Default Install Folder: /opt/ibm/java-x86_64-80

ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT

:

===============================================================================

Pre-Installation Summary

————————

Please Review the Following Before Continuing:

 

Product Name:

IBM® 64-bit Runtime Environment for Linux®, v8.0

Install Folder:

/opt/ibm/java-x86_64-80

Disk Space Information (for Installation Target):

Required: 181,926,137 Bytes

Available: 14,344,933,376 Bytes

 

PRESS <ENTER> TO CONTINUE:

===============================================================================

Installing…

————-

[==================|==================|==================|==================]

[——————|——————|——————|——————]

===============================================================================

Installation Complete

———————

Congratulations. IBM® 64-bit Runtime Environment for Linux®, v8.0 has been

successfully installed to:

/opt/ibm/java-x86_64-80

PRESS <ENTER> TO EXIT THE INSTALLER:

 

We now have installed IBM 8 JRE into:

/opt/ibm/java-x86_64-80

 

To change the JRE current version or use a different vendor i.e. in our case we wish to use IBM’s JRE as opposed to the default CentOS JRE, we can choose one of several options:

  • Use JAVA_HOME
  • Use a server.env file

Using JAVA_HOME in .bash_profile

JAVA_HOME will ensure that the current logged in user will use the specified JRE when several applications/products on the same machine refer to JAVA_HOME, this may not be what you want. But if this machine is only for Liberty then this is an easy choice.

 

Steps:

  • First we will verify the current JRE that is set for your environment, so we can test later that it has been changed.
java -version

Result:

java version “1.7.0_91″
OpenJDK Runtime Environment (rhel-2.6.2.1.el7_1-x86_64 u91-b00)

OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

 

We will now need to set our environment buy editing .bash_profile

We want to set JAVA_HOME to where we have our JDK installed for example:

export JAVA_HOME=/opt/ibm/java-x86_64-80/jre

If JAVA_HOME/bin is not in the PATH, add it to the path:

export PATH=$JAVA_HOME/bin:$PATH

 

  • Edit your local bash profile (~/.bash_profile) and add two lines:
#Liberty
JAVA_HOME=/opt/ibm/java-x86_64-80/jre

PATH=$JAVA_HOME/bin:$PATH

 

export PATH

export JAVA_HOME

Example .bash_profile

We can either logout and re-login for the changes to take effect or we can source (execute) .bash_profile from our current session:

  • Now check what JRE is running for example:
which java

Result:

/opt/ibm/java-x86_64-80/jre/bin/java
  • We can now start an existing Liberty Server for example we have a liberty instance installed in /var/apps/wasnd855_lp/ and we have created a server called server1
/var/apps/wasnd855_lp/bin/server start server1

We can see that JRE used by looking at console.log for example:

cat /var/apps/wasnd855_lp/usr/servers/server1/logs/console.log

 

Result:

Launching server1 (WebSphere Application Server 8.5.5.0/wlp-1.0.3.20130510-0831) on IBM J9 VM, version pxa6480sr2-20151023_01 (SR2) (en_GB)
[AUDIT ] CWWKE0001I: The server server1 has been launched.

[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.

[AUDIT ] CWWKF0011I: The server server1 is ready to run a smarter planet.

 

We can now see that Liberty is now using the IBM JRE as opposed to the default CentoOS OpenJDK, but the issue is that now IBM JRE will be used for all application/software that refer to Java_HOME, and we may not want this. We may wish to have only Liberty use the IBM JRE. To do this we must refer to a server.env file.

 

Specifying JAVA_HOME using server.env

Before we do this, we will remove the edits made to .bash_profile to ensure that JAVA_HOME is not set as an environment variable.

[root@dmgr ~]# env | grep JAVA_HOME
[root@dmgr ~]# env | grep PATH

PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/IBM/InstallationManager/eclipse/tools/

QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins

We can see above that the JAVA_HOME variable is not set, and the PATH specifies /user/bin for example:

which java

Result:

/usr/bin/java

 

java -version

Result:

java version “1.7.0_91″
OpenJDK Runtime Environment (rhel-2.6.2.1.el7_1-x86_64 u91-b00)

OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

 

We can use server.env files at the install and server levels to specify environment variables such as JAVA_HOME, WLP_USER_DIR, and WLP_OUTPUT_DIR. These files support only KEY=value pairs. Shell and variable expansion are not supported.

The server management script will search for server.env files in two locations, ${wlp.install.dir}/etc/server.env and ${server.config.dir}/server.env. If both files are present, the contents of the two server.env files will be merged, with values in the the server-level file taking precedence over values in the runtime-level file.

Steps:

We will use a variable fro JAVA_HOME in a file called server.env, in this example it will be placed in the <installroot/>etc/server.env for example: /var/apps/wasnd855_lp/etc

  • Stop the server.
  • Create a file called /var/apps/wasnd855_lp/etc/server.env
mkdir -p /var/apps/wasnd855_lp/etc/

 

touch /var/apps/wasnd855_lp/etc/server.env

 

  • Edit the file with your favourite editor (I just logged in using WinSCP an used the default text editor) and set the JAVA_HOME variable to point to the JRE you want to use for example:

 

  • Close the file and save your changes.
  • Start the server
/var/apps/wasnd855_lp/bin/server start server1
  • Check the console.log
cat /var/apps/wasnd855_lp/usr/servers/server1/logs/console.log

Result:

Launching server1 (WebSphere Application Server 8.5.5.0/wlp-1.0.3.20130510-0831) on IBM J9 VM, version pxa6480sr2-20151023_01 (SR2) (en_GB)
[AUDIT ] CWWKE0001I: The server server1 has been launched.

[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.

[AUDIT ] CWWKF0011I: The server server1 is ready to run a smarter planet.

 

Note that the version of the JRE listed in the console window now references the IBM 8 JRE Java version, as opposed to the current shell’s Java version.

 

 

 

facebooktwittergoogle_plusredditpinterestlinkedinmail

Viewing all articles
Browse latest Browse all 13

Trending Articles