The creators of
Java conceived an environment (VM language and standard libraries) that allows
development of programs with maximum portability. In theory, it is the VM, not
the developer, that deals with all the OS and hardware-related specificities.
Can we say,
then, that Java is totally portable, as Sun implies with its slogan, "Compile
once, run everywhere"?
The numerous
tests and portings that we have performed in the OpenVMS environment show that
Java programs are much more portable than those written in a compiled language.
However, we are still a long way from verifying total portability. The reason
is simple. The Java library creators, VM developers, and application developers
are mainly from the UNIX world and, therefore, are unfamiliar with OpenVMS.
(The OpenVMS VMs, Fast VM for Alpha, and HotSpot VM for Itanium systems, have
been ported from Tru64 UNIX and HP-UX, respectively; the majority of Java
applications were developed on and for UNIX platforms.)
Portability
problems can be divided into two categories:
- Problems for the OpenVMS system engineer
- Problems for the Java application developer
The problems the
system engineer encounters most often concern files and DCL, and these problems
can be resolved without recompiling the application. For a description, see the
User Guide for Java for OpenVMS.
Java deals only
with files whose format is Stream-LF. Consequently, the system engineer must
ensure that all the Java application files (bytecode, jar
archive, data files, and so on) respect this format. Having originated in UNIX,
the majority of Java applications use file names that do not respect ODS-2 file
semantics. If this is the case then it is vital that the file system be
migrated to ODS-5 format immediately, and that the Java application process is
run with the correct parameters. For example, the following commands are often
used:
$ SET PROCESS/PARSE=EXTENDED
$ DEFINE DECC$EFS_CASE_PRESERVE ENABLE
$ DEFINE DECC$ARGV_PARSE_STYLE ENABLE
$ DEFINE DECC$EFS_CHARSET ENABLE
$ DEFINE DECC$EFS_CASE_SPECIAL ENABLE
$ DEFINE DECC$ENABLE_GETENV_CACHE ENABLE
$ DEFINE DECC$POSIX-SEEK_STREAM_FILE ENABLE
$ DEFINE DECC$FILE_SHARING ENABLE
$ DEFINE JAVA$FILENAME_CONTROLS 8
|
In the preceding
list, the first two commands force the process to respect case, and the last
command defines the UNIX and OpenVMS file-name mapping rules that the VM must
use. Sometimes choosing the good value for these logical names can be a
delicate matter.
Java ignores the
notion of file versions. Because of this, a good practice is to limit file
versions to one on all files in the Java application file hierarchy. To do
this, use the following commands on the root folder of the hierarchy:
$ SET DIRECTORY/VERSION_LIMIT=1 disk:[rootfolder...]
$ SET FILE/VERSION_LIMIT=1 disk:[rootfolder...]*.*;*
|
The remaining
task is to translate the application startup scripts into DCL procedures. You
must use the foreign command JAVA to launch Java applications. This
command can take either of the following two forms:
$ JAVA bytecode
$ JAVA -jar archive-jar
|
The bytecode
name corresponds to the Java class name in the source code. Because Java is
case sensitive (unlike DCL) the bytecode name must be quoted to deal with this
difference. For example:
The JAVA
command accepts several optional parameters, including the classpath,
which indicates the location of the bytecodes. These parameters can sometimes
cause the final command line to exceed the DCL limit for commands within a
procedure. For OpenVMS Version 7.3-2, this limit is set to 8192 bytes, and the JAVA
command must be modified to respect this limit. OpenVMS provides various
workarounds to accomplish this (for example, option file, classpath
file; logical names such as JAVA$ENABLE_ENVIRONMENT_EXPANSION, JAVA$CLASSPATH,
and so on).
The problems the
Java developer encounters most often concern process management (such as fork,
environment variables) and can be only resolved by modifying the source code
and recompiling the application. These problems are illustrated by the iReport
application, a reporting tool drawn from Microsoft® Access and Crystal Report.
The iReport tool
uses an external program (for example, XPDF or Mozilla) to display the report
in PDF or HTML format. This program runs within a detached process. On OpenVMS,
the display works fine locally but fails remotely. The reason is that the X11
parameters (display node, display transport) are
logical names that are not passed to the child process (display) by the parent
process (iReport). We had to modify the
source file (iReportCompiler.java) in order for the
iReport process to pass the X11 parameters to the process controlling the
display.
Use of the logical name JAVA$EXEC_TRACE
can be useful for diagnosing portability problems related to process
management. Once set to "true" in the LNM$JOB table, this logical
name forces the VM to trace calls to the POSIX function execv() as well as its list of arguments.
|