[Previous Example | Next Example | Main Tutorial Page]

Message queue: Example 2 of 3

Use the following as an example for your program.

//////////////////////////////////////////////////////////////////////////////////
//
// Example using the Message Queue function of the IBM Toolbox for Java
//
//////////////////////////////////////////////////////////////////////////////////
//
// This source is an example of IBM Toolbox for Java "Message Queue".
// IBM grants you a nonexclusive license to use this as an example
// from which you can generate similar function tailored to
// your own specific needs.
//
// This sample code is provided by IBM for illustrative purposes
// only. These examples have not been thoroughly tested under all
// conditions. IBM, therefore, cannot guarantee or imply
// reliability, serviceability, or function of these programs.
//
// All programs contained herein are provided to you "AS IS"
// without any warranties of any kind.  The implied warranties of
// merchantability and fitness for a particular purpose are
// expressly disclaimed.
//
// IBM Toolbox for Java
// (C) Copyright IBM Corp. 1999
// All rights reserved.
// US Government Users Restricted Rights -
// Use, duplication, or disclosure restricted
// by GSA ADP Schedule Contract with IBM Corp.
//
//////////////////////////////////////////////////////////////////////////////////

package examples;


import java.io.*;
import java.util.*;
import com.ibm.as400.access.*;

public class displayMessages extends Object
{

   public static void main(String[] parameters)
   {
      displayMessages me = new displayMessages();

      me.Main(parameters);

      System.exit(0);
   }


   void displayMessage()
   {
   }


   void Main(String[] parms)
   {
      try
      {

          AS400 system = new AS400(); 1 Click to display a detailed explanation


                     if (parms.length > 0)
                        system.setSystemName(parms[0]); 2 Click to display a detailed explanation

      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }
}

  1. A program uses the AS400 object to designate which AS/400 to connect to. With one exception, all programs that need resources from an AS/400 must have an AS/400 object. The exception is JDBC. If your program uses JDBC, then the IBM Toolbox for Java JDBC driver creates the AS400 object for the program.

  2. This program assumes the first command line parameter is the name of the AS/400. If a parameter is passed to the program, the setSystemName method of the AS400 object is used to set the system name. The AS400 object also needs AS/400 sign-on information:

    1. If the program is running on a workstation, the IBM Toolbox for Java program prompts the user for a user ID and password. Note: If a system name is not specified as a command line parameter, the AS400 object also prompts for the system name.
    2. If the program is running on the AS/400's Java Virtual Machine (JVM), then the user ID and password of the user running the Java program is used. In this case, the user does not specify a system name, but lets the system name default to the name of the system that the program is running on.




Previous

Next