[ Previous part | Next part | Simple programming examples ]

Example: Using message queues (part 2 of 3)

Use the following as an example for your program. The example includes detailed explanations about key lines in the code. You can view the detailed explanations in the following ways:

Note: Read the Code example disclaimer for important legal information.

//////////////////////////////////////////////////////////////////////////////////
//
// Example using the Message Queue function of the IBM Toolbox for Java
//
// This source is an example of IBM Toolbox for Java "Message Queue".
//
//////////////////////////////////////////////////////////////////////////////////

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(); Note 1 Click to display a detailed explanation


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

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

  1. A program uses the AS400 object to designate which server to connect to. With one exception, all programs that need resources from a server must have an AS400 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 server. 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 server sign-on information:

[ Previous part | Next part | Simple programming examples ]