All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.JavaApplicationCall

java.lang.Object
   |
   +----com.ibm.as400.access.JavaApplicationCall

public class JavaApplicationCall
extends Object
implements Serializable

The JavaApplicationCall class provides an easy way to run Java applications on the AS/400's Java Virtual Machine from a client. The client Java program specifies the environment, program to run and program parameters. The program then runs on the AS/400's Java Virtual Machine. Text based input/output is provided by JavaApplicationCall. Input can be sent to the Java program which will receive the input via standard input. Standard output and standard error text generated by the Java program are received by JavaApplicationCall and made available to the calling program. JavaApplicationCall does not support displaying the graphical user interface of the AS/400 Java program on the clinet. Other Java facilities, such as remote AWT must be used to display graphical interfaces on the client.

Sockets are used to send Standard input, output and error between client and server. The port used can be set via setPort(). The default port is 2850, 2851 and 2852. If the port is in use, this class searches for available ports if findPort is true. Standard input, output and error are not transported across a secure connection even when the rest of the Toolbox is using SSL.

For example, supposed Java class HelloWorld resides in directory /javatest on the AS/400. The following calls this program and receives program output written to standard out.

 import com.ibm.as400.access.*;
 public class test implements Runnable
 {
    JavaApplicationCall jaCall;
    public static void main(String[] args)
    {
       test me = new test();
       me.Main(args);
    }
    void Main(String[] args)
    {
       try
       {
           // Construct an AS/400 object.  The Java program is on this AS/400.
           AS400 as400 = new AS400();
           // Construct a JavaApplicationCall object.
           jaCall = new JavaApplicationCall(as400);
           // Set the Java application to be run.
           jaCall.setJavaApplication("HelloAS400");
           // Set the classpath environment variable used by the AS/400's
           // JVM so it can find the class to run.
           jaCall.setClassPath("/javatest");
           // Start the thread that will receive standard output
           Thread outputThread = new Thread(this);
           outputThread.start();
           // Start the program.  The call to run() will not return
           // until the AS/400 Java program completes.  If the Toolbox
           // cannot start the Java program, false is returned with
           // a list of AS/400 message objects indicating why the program
           // could not start.
           if (jaCall.run() != true)
           {
                AS400Message[] messageList = jaCall.getMessageList();
                for (int msg = 0; msg < messageList.length; msg++)
                    System.out.println(messageList[msg].toString());
           }
       }
       catch (Exception e) { e.printStackTrace(); }
       System.exit(0);
    }
    // This thread will get standard out from the AS/400 Java
    // program and print it.  Note the call to sleep.  JavaApplication
    // call returns immediately even if there is no data.
    public void run()
    {
        while(true)
        {
           String s = jaCall.getStandardOutString();
           if (s != null)
             System.out.println(s);
           try { Thread.sleep(100); } catch (Exception e) {}
        }
    }
 }
 


Constructor Index

 o JavaApplicationCall()
Constructs a JavaApplicationCall object.
 o JavaApplicationCall(AS400)
Constructs a JavaApplicationCall object.
 o JavaApplicationCall(AS400, String)
Constructs a JavaApplicationCall object.
 o JavaApplicationCall(AS400, String, String)
Constructs a JavaApplicationCall object.

Method Index

 o addActionCompletedListener(ActionCompletedListener)
Adds an ActionCompletedListener to be notified when the Java application ends.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property changes.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property changes.
 o getClassPath()
Returns the value of the CLASSPATH environment variable when running the Java program.
 o getDefaultPort()
Returns the default port used to transfer standard in, standard out and standard error between the client and the server.
 o getGarbageCollectionFrequency()
Returns the relative frequency that garbage collection runs.
 o getGarbageCollectionInitialSize()
Returns the initial size, in kilobytes, of the garbage collection heap.
 o getGarbageCollectionMaximumSize()
Returns the maximum size, in kilobytes, that the garbage collection heap can grow to.
 o getGarbageCollectionPriority()
Returns the priority of the tasks running garbage collection.
 o getInterpret()
Returns whether all Java class files should be run interpretively.
 o getJavaApplication()
Returns the name of Java application to be run.
 o getMessageList()
Returns the list of AS/400 messages generated if the Java program cannot be started.
 o getOptimization()
Returns the optimization level of AS/400 Java programs that will be created if no Java program is associated with the Java class.
 o getOptions()
Returns a list of special options used when running the Java class.
 o getParameters()
Returns parameter values that are passed to the Java application.
 o getProperties()
Returns the properties set on the AS/400's JVM before running the Java program.
 o getSecurityCheckLevel()
Returns the level of warnings given for directories in the CLASSPATH that have public write authority.
 o getStandardErrorString()
Returns the next string written to standard error by the program running on the AS/400.
 o getStandardOutString()
Returns the next string written to standard output by the application.
 o getSystem()
Returns the AS/400 system which contains the Java program.
 o isFindPort()
Indicates if this class should search for a free port.
 o removeActionCompletedListener(ActionCompletedListener)
Removes this ActionCompletedListener from the list of listeners.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener from the list of listeners.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener from the list of listeners.
 o run()
Run the Java application.
 o sendStandardInString(String)
Sends the standard input to the application running on AS/400.
 o setClassPath(String)
Sets the value of the CLASSPATH environment variable when running the Java program.
 o setDefaultPort(int)
Sets the default port.
 o setFindPort(boolean)
Sets searching for a free port.
 o setGarbageCollectionFrequency(int)
Sets the relative frequency that garbage collection runs.
 o setGarbageCollectionInitialSize(int)
Sets the initial size, in kilobytes, of the garbage collection heap.
 o setGarbageCollectionMaximumSize(String)
Sets the maximum size, in kilobytes, that the garbage collection heap can grow to.
 o setGarbageCollectionPriority(int)
Sets the priority of the tasks running garbage collection.
 o setInterpret(String)
Sets whether all Java class files should be run interpretively.
 o setJavaApplication(String)
Sets the Java application to be run.
 o setOptimization(String)
Sets the optimization level of the AS/400 Java program that will be created if no Java program is associated with the Java class.
 o setOptions(String[])
Sets special options used when running the Java class.
 o setParameters(String[])
Sets one or more parameter values that are passed to the Java application.
 o setProperties(Properties)
Sets the Java Virtual Machine properties when running the Java Application.
 o setSecurityCheckLevel(String)
Sets the level of warnings given for directories in CLASSPATH that have public write authority.
 o setSystem(AS400)
Sets the AS/400 system.

Constructors

 o JavaApplicationCall
 public JavaApplicationCall()
Constructs a JavaApplicationCall object.

 o JavaApplicationCall
 public JavaApplicationCall(AS400 system)
Constructs a JavaApplicationCall object. The Java program is on AS/400 system.

Parameters:
system - The AS/400 on which contains the Java program.
 o JavaApplicationCall
 public JavaApplicationCall(AS400 system,
                            String application)
Constructs a JavaApplicationCall object. The Java program is namee application and runs on system system.

Parameters:
system - The AS/400 on which contains the Java program.
application - The name of Java program.
 o JavaApplicationCall
 public JavaApplicationCall(AS400 system,
                            String application,
                            String classPath)
Constructs a JavaApplicationCall object. The Java program is namee application and runs on system system. classPath is passed to the AS/400 as the value of the CLASSPATH environment variable.

Parameters:
system - The AS/400 on which contains the Java program.
application - The name of Java program.
classPath - The value of the environment variable CLASSPATH.

Methods

 o addActionCompletedListener
 public void addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener to be notified when the Java application ends. The specified ActionCompletedListeners actionCompleted method will be called each time an application runs.

Parameters:
listener - The ActionCompletedListener.
See Also:
removeActionCompletedListener
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property changes.

Parameters:
listener - The listener.
See Also:
removePropertyChangeListener
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property changes.

Parameters:
listener - The listener.
See Also:
removeVetoableChangeListener
 o getClassPath
 public String getClassPath()
Returns the value of the CLASSPATH environment variable when running the Java program. Use the forward slash to separate path elements and a colon to separate the elements of CLASSPATH. For example, /dir1:/dir1/dir2/myClasses.jar.

Valid values are:

Returns:
The value of CLASSPATH.
 o getDefaultPort
 public int getDefaultPort()
Returns the default port used to transfer standard in, standard out and standard error between the client and the server. Three ports are used. The port returned by this method is used for standard in, port + 1 is used for standard out and port + 2 is used for standard error. The default port is 2850.

Returns:
The default port.
 o getGarbageCollectionFrequency
 public int getGarbageCollectionFrequency()
Returns the relative frequency that garbage collection runs. This value applies only to V4R2 and V4R3 versions of the AS/400. It is ignored in V4R4 and later versions of the AS/400.

Returns:
The relative frequency.
 o getGarbageCollectionInitialSize
 public int getGarbageCollectionInitialSize()
Returns the initial size, in kilobytes, of the garbage collection heap. A large size can keep the garbage collector from starting when the Java program is small, improving performance.

Possible values are:

Returns:
The initial size of the garbage collection heap.
 o getGarbageCollectionMaximumSize
 public String getGarbageCollectionMaximumSize()
Returns the maximum size, in kilobytes, that the garbage collection heap can grow to. This value is used to prevent runaway programs from consuming all available storage.

Possible values are:

Returns:
The maximum size that the garbage collection heap can grow to.
 o getGarbageCollectionPriority
 public int getGarbageCollectionPriority()
Returns the priority of the tasks running garbage collection. This value applies only to V4R2 and V4R3 versions of the AS/400. It is ignored in V4R4 and later versions of the AS/400.

Returns:
The priority of the tasks.
 o getInterpret
 public String getInterpret()
Returns whether all Java class files should be run interpretively.

Possible values are:

Returns:
Whether all Java class files should be run interpretively.
 o getJavaApplication
 public String getJavaApplication()
Returns the name of Java application to be run. If the Java application is not be set, null is returned.

Returns:
The name of Java application.
 o getMessageList
 public AS400Message[] getMessageList()
Returns the list of AS/400 messages generated if the Java program cannot be started. Before run() is called and if the Java program can be started, an empty list is returned.

Returns:
The array of AS400Message objects.
 o getOptimization
 public String getOptimization()
Returns the optimization level of AS/400 Java programs that will be created if no Java program is associated with the Java class. *INTERPRET means the resulting Java program interprets the class byte codes when invoked. For other optimization levels, the Java program contains machine instruction sequences that are run when the Java program is invoked. *INTERPRET Java programs are smaller but run slower than Java programs created with higher optimization levels. As you increase the optimization level beyond 10, the Java program performance generally improves, but the time required to create the Java program increases, and debugging is more difficult.

Possible values are:

Returns:
The optimization level of the AS/400 Java application.
 o getOptions
 public String[] getOptions()
Returns a list of special options used when running the Java class.

The possible values are:

Returns:
The options used when running the Java class.
 o getParameters
 public String[] getParameters()
Returns parameter values that are passed to the Java application. A maximum of 200 parameter values can be passed.

Returns:
The parameters when running the Java application.
 o getProperties
 public Properties getProperties()
Returns the properties set on the AS/400's JVM before running the Java program.

Returns:
The properties.
 o getSecurityCheckLevel
 public String getSecurityCheckLevel()
Returns the level of warnings given for directories in the CLASSPATH that have public write authority. A directory in the CLASSPATH that has public write authority is a security exposure because it may contain a class file with the same name as the one you want to run. Whichever class file is found first is run.

The possible values are:

Returns:
The level of warnings given for directories in the CLASSPATH that have public write authority.
 o getStandardErrorString
 public String getStandardErrorString()
Returns the next string written to standard error by the program running on the AS/400.

Returns:
the next standard error string from AS/400.
 o getStandardOutString
 public String getStandardOutString()
Returns the next string written to standard output by the application.

Returns:
the string written to standard output.
 o getSystem
 public AS400 getSystem()
Returns the AS/400 system which contains the Java program.

Returns:
The AS/400 system.
 o isFindPort
 public boolean isFindPort()
Indicates if this class should search for a free port.

Returns:
true if this class will search for a free port; false otherwise.
 o removeActionCompletedListener
 public synchronized void removeActionCompletedListener(ActionCompletedListener listener)
Removes this ActionCompletedListener from the list of listeners. If the ActionCompletedListener is not on the list, nothing is done.

Parameters:
listener - The ActionCompletedListener.
See Also:
addActionCompletedListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener from the list of listeners.

Parameters:
listener - The listener.
See Also:
addPropertyChangeListener
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener from the list of listeners.

Parameters:
listener - The listener.
See Also:
addVetoableChangeListener
 o run
 public boolean run() throws AS400SecurityException, ConnectionDroppedException, ErrorCompletingRequestException, InterruptedException, IOException, ServerStartupException, UnknownHostException
Run the Java application. Control will not be returned to the calling application until the program completes. If the program does not start, a list of AS400Message object containing information about is failure is available.

Returns:
true if the program can be started, false otherwise.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o sendStandardInString
 public void sendStandardInString(String data)
Sends the standard input to the application running on AS/400.

Parameters:
data - The standard input to AS/400.
 o setClassPath
 public void setClassPath(String classPath) throws PropertyVetoException
Sets the value of the CLASSPATH environment variable when running the Java program. Use the forward slash to separate path elements and a colon to separate the elements of CLASSPATH. For example, /dir1:/dir1/dir2/myClasses.jar.

Valid values are:

Parameters:
classPath - The value of the classpath.
Throws: PropertyVetoException
If the change is voted.
 o setDefaultPort
 public void setDefaultPort(int port) throws PropertyVetoException
Sets the default port. This is the port for standard in. Standard out is port + 1 and standard error is port + 2. SetFindPort() can be used to tell this class to search for a free port of these ports are in use.

Parameters:
port - The default port.
Throws: PropertyVetoException
If the change is voted.
 o setFindPort
 public void setFindPort(boolean search) throws PropertyVetoException
Sets searching for a free port.

Parameters:
search - true to search for a port that is not in use; false to not search.
Throws: PropertyVetoException
If the change is voted.
 o setGarbageCollectionFrequency
 public void setGarbageCollectionFrequency(int frequency) throws PropertyVetoException
Sets the relative frequency that garbage collection runs. This parameter is valid only for V4R2 and V4R3 versions of the AS/400. It is ignored for V4R4 and later versions of the AS/400.

Parameters:
frequency - The relative frequency that garbage collection runs.
Throws: PropertyVetoException
If the change is voted.
 o setGarbageCollectionInitialSize
 public void setGarbageCollectionInitialSize(int size) throws PropertyVetoException
Sets the initial size, in kilobytes, of the garbage collection heap. This is used to prevent garbage collection from starting on small programs.

The possible values are:

Parameters:
size - The initial size of the garbage collection heap.
Throws: PropertyVetoException
If the change is voted.
 o setGarbageCollectionMaximumSize
 public void setGarbageCollectionMaximumSize(String size) throws PropertyVetoException
Sets the maximum size, in kilobytes, that the garbage collection heap can grow to. This is used to prevent runaway programs that consume all of the available storage. Normally, garbage collection runs as an asynchronous thread in parallel with other threads. If the maximum size is reached, all other threads are stopped while garbage collection takes place. This may adversely affect performance.

The possible values are:

Parameters:
size - The maximum size that the garbage collection heap can grow to.
Throws: PropertyVetoException
If the change is voted.
 o setGarbageCollectionPriority
 public void setGarbageCollectionPriority(int priority) throws PropertyVetoException
Sets the priority of the tasks running garbage collection. This parameter is valid only for V4R3 and V4R2 versions of the AS/400. It is ignore for V4R4 and later versions of the AS/400.

Parameters:
priority - The priority of the tasks running garbage collection.
Throws: PropertyVetoException
If the change is voted.
 o setInterpret
 public void setInterpret(String interpret) throws PropertyVetoException
Sets whether all Java class files should be run interpretively.

The possible values are:

Parameters:
interpret - How all Java class files should be run interpretively.
Throws: PropertyVetoException
If the change is voted.
 o setJavaApplication
 public void setJavaApplication(String application) throws PropertyVetoException
Sets the Java application to be run.

Parameters:
application - The Java application to be run.
Throws: PropertyVetoException
If the change is voted.
 o setOptimization
 public void setOptimization(String opt) throws PropertyVetoException
Sets the optimization level of the AS/400 Java program that will be created if no Java program is associated with the Java class. For Java classes that are in a class file, the created Java program remains associated with the class file after the Java program is run. If the class is a part of a JAR or ZIP file, a temporary Java program is created to run from and then discarded. This can result in slow performance. For best performance, explicitly create a Java program for JAR and ZIP files with the Create Java Program (CRTJVAPGM) command. For *INTERPRET, the resulting Java program interprets the class byte codes when invoked. For other optimization levels, the Java program contains machine instruction sequences that are run when the Java program is invoked. INTERPRET Java programs are smaller but run slower than Java programs created with higher optimization levels. As you increase the optimization level beyond 10, the Java program performance generally improves, but the time required to create the Java program increases and debugging is more difficult.

The possible values are:

Parameters:
opt - The optimization level of the AS/400 Java program that will be created if no Java program is associated with the Java class.
Throws: PropertyVetoException
If the change is voted.
 o setOptions
 public void setOptions(String option[]) throws PropertyVetoException
Sets special options used when running the Java class. This method is not additive. The list of values is replaced every time this method is called.

The possible values are:

Parameters:
option - The special options used when running the Java class.
Throws: PropertyVetoException
If the change is voted.
 o setParameters
 public void setParameters(String parameters[]) throws PropertyVetoException
Sets one or more parameter values that are passed to the Java application. A maximum of 200 parameter values can be passed.

Parameters:
parameters - The parameters for the Java application.
Throws: PropertyVetoException
If the change is voted.
 o setProperties
 public void setProperties(Properties property) throws PropertyVetoException
Sets the Java Virtual Machine properties when running the Java Application.

Parameters:
properties - The JVM properties.
Throws: PropertyVetoException
If the change is voted.
 o setSecurityCheckLevel
 public void setSecurityCheckLevel(String chklvl) throws PropertyVetoException
Sets the level of warnings given for directories in CLASSPATH that have public write authority. A directory in CLASSPATH that has public write authority is a security exposure because it may contain a class file with the same name as the one you want to run. Whichever class file is found first is run.

The possible values are:

Parameters:
chklvl - The level of warnings given for directories in the CLASSPATH that have public write authority.
Throws: PropertyVetoException
If the change is voted.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the AS/400 system.

Parameters:
system - The AS/400 system.
Throws: PropertyVetoException
If the change is voted.

All Packages  Class Hierarchy  This Package  Previous  Next  Index