Chapter 2
Using RTL and SYS Calls
2.1 Goal of This Chapter
This book is going to lay the groundwork for you to create all of the tools you need to make Java a usable language on OpenVMS. While I’m certainly not going to code a method for each and every SYS$ and RTL function existing on the platform, we are going to code a package which contains methods for most of the functions used in prior versions of our application. We barely dented the surface, but their should be enough for you to begin learning Java by cutting and pasting to add new methods for additional function calls.
We will create VMS RTL classes for lib$spawn() and lib$set_logical(). In addition we w ill create a V M SD ate class w hich w ill contain the m ethod s for lib$init_date_time_context(), lib$free_date_time_context(), lib$format_date_time(), and lib$convert_date_string(). The reason we will be splitting the date stuff out into its own class is I want the class destructor (finalizer in Java speak) to always clean up the date time context. Due to the nature of lib$do_command() never returning, I won’t be showing you how to call that funcion.
We won’t be covering calling lib$cvt_dx_dx() in this chapter. The only time you would need it is if you are reading a file created by older BASIC or COBOL programs. When we cover interfacing with RMS Indexed files, we will call it there.
It is my hope that you find the journey through this chapter worth your while. I think it will be much more useful to a seasoned developer than all of the canned 15 line example snippets you find in other books.
2.2 Order of Development with JNI
When you will be writing Java classes which use the Java Native Interface development must proceed in the following order:
• Code the Java class
• Create a directory tree if working with packages
• Run javah against the class file to create a header file
• Code your C/C++ program or module
• Create a linker options file for the C module
• Link a shareable image out of your object and options file
• Define a logical which points to your shareable image
After looking at the above list, most of you are probably beginning to understand why most books on Java choose to talk about creating generic applets and Web pages. The hack at it - try it - hack at it - try it approach works well for Java applets, not requiring you to think too far ahead. You actually have to do a little bit of design work when using JNI.