You always have at least two ways to access a server resource
when your Java™ program is running on the IBM® Developer
Kit for Java (IBM i) Java
virtual machine (JVM).
You can use either of the following interfaces:
- Facilities built into Java
- An IBM Toolbox for Java class
When deciding which interface to use, consider the following
factors:
- Location - Where a program runs is the most important factor
in deciding which interface set to use. Does the program do the following:
- Run only on the client?
- Run only on the server?
- Run on both client and server, but in both cases the resource
is an IBM i resource?
- Run on one IBM i JVM
and access resources on another IBM i server?
- Run on different kinds of servers?
If the program runs on both client and server (including an IBM i server as a client
to a second IBM i server)
and accesses only IBM i resources,
it may be best to use the IBM Toolbox for Java interfaces.
If
the program must access data on many types of servers, it may be best
to use Java native interfaces.
- Consistency / Portability - The ability to run IBM Toolbox
for Java classes on the IBM i server means that
the same interfaces can be used for both client programs and server
programs. When you have only one interface to learn for both client
programs and server programs, you can be more productive.
Writing
to IBM Toolbox for Java interfaces
makes your program less server portable, however.
If
your program must connect to an IBM i server as well as
other servers, you may find it better to use the facilities that are
built into Java.
- Complexity - The IBM Toolbox for Java interface
is built especially for easy access to an IBM i resource. Often, the
only alternative to using the IBM Toolbox
for Java interface is to write a program that accesses
the resource and communicates with that program through Java Native Interface (JNI).
You must decide
whether it is more important to have better Java neutrality
and write a program to access the resource, or to use the IBM Toolbox
for Java interface, which is less portable.
- Function - The IBM Toolbox for Java interface
often provides more function than the Java interface.
For example, the IBM Toolbox for Java IFSFileOutputStream
class has more function than the FileOutputStream class of java.io.
However, you lose server portability by using the IBM Toolbox
for Java class.
You must decide whether portability
is more important or whether you want to take advantage of the additional
function.
- Resource - When running on the IBM i JVM, many of the IBM Toolbox
for Java classes still make requests through the
host servers. Therefore, a second job (the server job) carries out
the request to access a resource.
This request may take more
resource than a Java native interface that runs
under the job of the Java program.
- IBM i server
as a client - If your program runs on one IBM i server and accesses
data on a second IBM i server,
your best choice may be to use IBM Toolbox
for Java classes. These classes provide easy access
to the resource on the second IBM i server.
An example of this is Data Queue access. The IBM Toolbox
for Java Data Queue interfaces provide easy access
to the data queue resource.