setmqenv

Use the setmqenv command to set up the IBM® MQ environment on UNIX, Linux®, and Windows.

Purpose

You can use the setmqenv command to automatically set up the environment for use with an installation of IBM MQ. Alternatively, you can use the crtmqenv command to create a list of environment variables and values to manually set each environment variable for your system; see crtmqenv for more information.
Note: Any changes you make to the environment are not persistent. If you log out, and log in again, your changes are lost.

You can specify which installation the environment is set up for by specifying a queue manager name, an installation name, or an installation path. You can also set up the environment for the installation that issues the setmqenv command by issuing the command with the -s parameter.

The setmqenv command sets the following environment variables, appropriate to your system:
  • CLASSPATH
  • INCLUDE
  • LIB
  • MANPATH
  • MQ_DATA_PATH
  • MQ_ENV_MODE
  • MQ_FILE_PATH
  • MQ_JAVA_INSTALL_PATH
  • MQ_JAVA_DATA_PATH
  • MQ_JAVA_LIB_PATH
  • MQ_JAVA_JVM_FLAG
  • MQ_JRE_PATH
  • PATH
On UNIX and Linux systems, if the -l or -k flag is specified, the LIBPATH environment variable is set on AIX®, and the LD_LIBRARY_PATH environment variable is set on HP-UX, Linux, and Solaris.

Usage notes

  • If you have installed IBM MQ V 7.0.1, do not use the setmqenv command. Some of the components of IBM MQ V 7.0.1, such as Explorer, reference the environment variables for their library paths and therefore will not work if the setmqenv command has been used to alter the environment variables to point to an IBM MQ V 7.0.1 installation path.
  • The setmqenv command removes all directories for all IBM MQ installations from the environment variables before adding new references to the installation for which you are setting up the environment for. Therefore, if you want to set any additional environment variables that reference IBM MQ, set the variables after issuing the setmqenv command. For example, if you want to add MQ_INSTALLATION_PATH/java/lib to LD_LIBRARY_PATH, you must do so after running the setmqenv command.
  • In some shells, command-line parameters cannot be used with setmqenv and any setmqenv command issued is assumed to be a setmqenv -s command. The command produces an informational message that the command has been run as if a setmqenv -s command had been issued. Therefore, in these shells you must ensure that you issue the command from the installation for which you want to set the environment for. In these shells, you must set the LD_LIBRARY_PATH variable manually. Use the crtmqenv command with the -l or -k parameter to list the LD_LIBRARY_PATH variable and value. Then use this value to set the LD_LIBRARY_PATH.

Syntax

Read syntax diagramSkip visual syntax diagram setmqenv -mQMgrName-nInstallationName-pInstallationPath-r-s -k-l -xMode

Optional Parameters

-m QMgrName
Set the environment for the installation associated with the queue manager QMgrName.
-n InstallationName
Set the environment for the installation named InstallationName.
-p InstallationPath
Set the environment for the installation in the path InstallationPath.
-r
Remove all installations from the environment.
-s
Set the environment for the installation that issued the setmqenv command.
-k
UNIX and Linux only.
Include the LD_LIBRARY_PATH or LIBPATH environment variable in the environment, adding the path to the IBM MQ libraries at the start of the current LD_LIBRARY_PATH or LIBPATH variable.
-l
UNIX and Linux only.
Include the LD_LIBRARY_PATH or LIBPATH environment variable in the environment, adding the path to the IBM MQ libraries at the end of the current LD_LIBRARY_PATH or LIBPATH variable.
-x Mode
Mode can take the value 32 or 64.
Create a 32-bit or 64-bit environment. If this parameter is not specified, the environment matches that of the queue manager or installation specified in the command.
Any attempt to display a 64-bit environment with a 32-bit installation fails.

Return codes

Return code Description
0 Command completed normally.
10 Command completed with unexpected results.
20 An error occurred during processing.

Examples

The following examples assume that a copy of IBM MQ is installed in the /opt/mqm directory on a UNIX or Linux system.
Note: The period character (.) character used at the beginning of each command makes the setmqenv script run in the current shell. Therefore, the environment changes made by the setmqenv script are applied to the current shell. Without the period character (.), the environment variables are changed in another shell, and the changes are not applied to the shell from which the command is issued.
  • The following command sets up the environment for an installation installed in the /opt/mqm directory:
    
    . /opt/mqm/bin/setmqenv -s
    
  • The following command sets up the environment for an installation installed in the /opt/mqm2 directory, and includes the path to the installation at the end of the current value of the LD_LIBRARY_PATH variable:
    
    . /opt/mqm/bin/setmqenv -p /opt/mqm2 -l
    
  • The following command sets up the environment for queue manager QM1 in a 32-bit environment:
    
    . /opt/mqm/bin/setmqenv -m QM1 -x 32
    
The following example assumes that a copy of IBM MQ is installed in C:\Program Files\IBM\WebSphere MQ on a Windows system.
This command sets up the environment for an installation called Installation1:

"C:\Program Files\IBM\WebSphere MQ\bin\setmqenv.cmd" -n Installation1