setmqenv (set IBM MQ environment)

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


Purpose

We 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 the system; see crtmqenv (create IBM MQ environment) 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.

We can specify which installation the environment is set up for by specifying a queue manager name, an installation name, or an installation path. We 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 the system:

  • CLASSPATH
  • INCLUDE
  • LIB
  • MANPATH
  • MQ_DATA_PATH
  • MQ_ENV_MODE
  • MQ_FILE_PATH
  • MQ_INSTALLATION_NAME
  • MQ_INSTALLATION_PATH
  • MQ_JAVA_INSTALL_PATH
  • MQ_JAVA_DATA_PATH
  • MQ_JAVA_LIB_PATH
  • MQ_JAVA_JVM_FLAG
  • MQ_JRE_PATH
  • PATH


Usage notes

  • The setmqenv command removes all directories for all IBM MQ installations from the environment variables before adding new references to the installation for which we are setting up the environment for. Therefore, if we want to set any additional environment variables that reference IBM MQ, set the variables after issuing the setmqenv command. For example, if we want to add MQ_INSTALLATION_PATH/java/lib to LD_LIBRARY_PATH, we 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 we must ensure that we issue the command from the installation for which we 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

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
    Applies to UNIX and Linux only. If the -k flag is specified:

    • On AIX, the LIBPATH environment variable is set.
    • On Linux, the LD_LIBRARY_PATH environment variable is set.

    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
    Applies to UNIX and Linux only. If the -l flag is specified:

    • On AIX, the LIBPATH environment variable is set.
    • On Linux, the LD_LIBRARY_PATH environment variable is set.

    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\MQ on a Windows system. This command sets up the environment for an installation called Installation1:

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


Related reference


Related information