The latest version of this Web page is available as http://www.theoffice.net/abcoates/NetRexx/nr/.

nr -
a Batch File System
for NetRexx and Java

Anthony B. Coates

abcoates@TheOffice.net


Contents

  1. What is NetRexx?

  2. What is "nr"?

  3. How is "nr" used?

  4. Downloading

  5. Thanks


/\

What is NetRexx?

NetRexx is a language based on Mike Cowlishaw's embeddable scripting language, Rexx. Rexx is well-known to OS/2, Amiga, and IBM mainframe users. As a scripting language, it offers comparable facilities to those of Unix shells.

NetRexx, however, is based on Java. Effectively, NetRexx offers a simplified and more human-oriented syntax for Java. It is particularly good for shorter, batch-style programs, where the demands of Java's syntax make Java less appealing. However, NetRexx makes Java's API fully available just as a Java programmer would expect, so it can be quite effectively used for programs of any complexity.

The NetRexx compiler, "NetRexxC", converts NetRexx programs to Java, and then compiles them using "javac". As such, NetRexx classes can interoperate seamlessly with compiled Java classes. Unlike Rexx, NetRexx is not interpreted, though there are continuing rumours of a NetRexx interpreter in the not-too-distant future.


/\

What is "nr"?

Since NetRexx is such a good language for writing batch scripts, it is a nuisance that NetRexx programs need to be compiled. What 'nr' is not is an interpreter. What 'nr' is, instead, is a compiling class loader. Java programs can define their own class loader, which is responsible for finding classes on the class path and loading them dynamically as required.

So, 'nr' works as follows: you give 'nr' the name of a Java class file with a "main" method, and 'nr' tries to load it. While loading, 'nr' checks the class file (and any others it requires) using the available 'nr' compiler classes (compiler classes to access "NetRexxC" and "javac" are provided). If the required class file does not exist but a compiler can generate it, or if a compiler reports that a source file newer than the class file exists, then 'nr' compiles the source on the fly, and loads the required class once the compilation is done.

So, you edit your NetRexx or Java file, run it using 'nr', and you don't have to worry about compiling it. Nothing to forget about. The convenience of an interpreted batch language, but with the speed of a compiled language (at least on the 2nd or 3rd time you run the script without changes). This is what Python users have come to expect, but NetRexx and Java users have been missing out on.

By the way, 'nr' is written in NetRexx, so you need to have "NetRexxC.zip" from the NetRexx distribution in your Java class path.


/\

How is "nr" used?

Typical usage for 'nr' is to use a batch file called 'nr', and a command line something like

nr myClass arg1 arg2 arg3 ...

or just

nr

to get a list of the available command line options for 'nr'. To get informational messages about what 'nr' is compiling and loading (including error messages if your NetRexx or Java sources don't compile), use

nr -vlc myClass arg1 arg2 arg3 ...

(use '-vc' just to get compiling information, and '-vl' just to get linking information).

If 'nr' is called directly, without the aid of a batch file, the command line looks like

java -classpath "<nr JAR file + normal class path>"
<options> "-Dnetrexx.path=..."
net.theoffice.abcoates.nr.nr
myClass arg1 arg2 arg3 ...

(with all of the above on the one command line). The "-Dnetrexx.path=..." option sets the path that 'nr' searches for NetRexx classes and sources. The standard Java class path is searched for Java classes and sources. Note that 'nr' will load classes from JAR files on the Java class path, but will not compile such classes. Also, 'nr' will not compile any class with a package name that starts with "java." or "netrexx.".

Importantly, 'nr' assumes that the class files for your NetRexx and Java batch scripts are in the same directories as their matching sources. This should be reasonable for batch scripts, which is what 'nr' aims to do well. If you need to keep classes and sources in separate directories, then 'nr' may not be the tool for you.

For "<options>", it is recommended that you turn off your just-in-time compiler, since it can increase the time required to run short batch scripts. To turn off your just-in-time compiler, try

The 'nr' distribution comes with sample batch scripts for running 'nr' using OS/2, Windows, or a Unix shell. You will need to edit these scripts to set the correct directories, and to set Java options such as "-nojit". If you have any questions, please send them to "abcoates@TheOffice.net". I will try to answer all questions, but I do not check my e-mail every day, so please give me a few days to reply.


/\

Downloading

Note: 'nr' is provided free, without any warranties, express or implied. Use for your own enjoyment, but at your own risk. All care taken, but no responsibility taken, etcetera. You get the idea.


/\

Thanks

The 'nr' utility was developed using IBM's JDK 1.1.8 GA for OS/2 Warp 4.
Let us hope that there will always be a client version of OS/2 Warp, for the sake of Java developers.
OS/2 is a rather nice platform for Java developers, and I hope never to be forced to change.

Special thanks to Mike Cowlishaw, living legend and author of NetRexx, for helping me understand how "NetRexxC" goes about compiling, and for adding a method that allows 'nr' to work as planned.

Last updated: 28 January 2000.