TOC Previous Next
Sample programs
This section contains some simple programs to show how to test and take advantage of the Java Bridge functionality found in Zend Platform for i5/OS.
Simple test program
The program in Example 6-1 shows how to get all of the Java system properties and iterate through them, printing all key/value pairs out to the screen.
Example 6-1 Print all Java system properties
The output from running this PHP program looks similar to Figure 6-2.
Figure 6-2 Output from running Java system properties program
IBM Toolbox for Java and PHP
This section shows two sample programs that access i5/OS resources via the IBM Toolbox for Java.
Restriction: Only a few Toolbox functions were executed when this chapter was written. Comprehensive testing of all functionality has not been done. For example, at the time this chapter was written the ability to run commands on i5/OS via the ibm.com .as400.access.CommandCall class did not work. |
Message queue test program
Example 6-2 shows a simple program to display the contents of an i5/OS message queue. You should first make sure that there are messages in the queue to see output.
Example 6-2 Display all messages in i5/OS message queue
The output from this program looks similar to Figure 6-3 (if there are messages in the queue).
Figure 6-3 Output from running Java Toolbox message queue program
Data queue test program
Example 6-3 shows how to post and peek entries from an i5/OS data queue. We test for the existence of the data queue - if it doesn't exist, we create it. If it does, we clear its contents.
Example 6-3 Manipulate i5/OS data queue
Figure 6-4 shows the output from the program in Example 6-3.
Figure 6-4 Output from running Java Toolbox data queue program
TOC Previous Next