![]() |
The NetRexx Tutorial
![]() |
Sun directly distributes the JDK for Windows/95, Windows/NT and Solaris (both SPARC and x86). The download can be performed from:
http://java.sun.com/products/jdk/1.1/index.html
Select the platform, read the download condition, and fetch the code using your preferred WEB browser.
NOTE: due to a problem with Netscape 3.01, I was forced to directly issue the FTP commands, in order to fetch the code.
ftp ftp.javasoft.com > anonymous > YOUR_EMAIL_ADDRESS > bin > cd pub/jdk1.1 > get jdk1.1.1-win32-x86.exe > quit
Using your preferred editor, enter the following program, calling it hellojava.java.
+----------------------------------------------------------------------+ | class hellojava |01 | { |02 | public static void main (String args[]) |03 | { |04 | System.out.println("Hello World, from Java!"); |05 | } |06 | } |07 +----------------------------------------------------------------------+ hellojava.java | ![]() |
Then you type:
>javac hellojava.java # compile the program >java hellojava # run it
If the output is the string "Hello World, from Java!" then you've almost done it!
Now you can try an applet. So edit the files hellojavaa.java and hellojavaa.html, as presented below.
+----------------------------------------------------------------------+ | import java.applet.Applet; |01 | import java.awt.Graphics; |02 | |03 | public class hellojavaa extends Applet { |04 | public void paint(Graphics g) { |05 | g.drawString("Hello world, from Java Applet!", 50, 25); |06 | } |07 | } |08 | |09 +----------------------------------------------------------------------+ hellojavaa.java | ![]() |
+----------------------------------------------------------------------+ | <HTML> |01 | <HEAD> |02 | <TITLE> Hello World </TITLE> |03 | </HEAD> |04 | <BODY> |05 | This is the applet:<P> |06 | <APPLET codebase="classes" code="hellojavaa.class" width=200 height=2|07 | </BODY> |08 | </HTML> |09 +----------------------------------------------------------------------+ hellojavaa.html |
>javac hellojavaa.java # compile the program >appletviewer hellojavaa.html # run it
There is a bug in the AIX JIT compiler. This leads to errors like the following one, even in compiling the small hello.nrx program.
$java COM.ibm.netrexx.process.NetRexxC hello NetRexx portable processor, version 1.120 Copyright (c) IBM Corporation, 1997. All rights reserved. Program hello.nrx java.lang.ArrayIndexOutOfBoundsException: 20 at netrexx.lang.RexxWords.space(Compiled Code) at netrexx.lang.Rexx.space(Compiled Code) at netrexx.lang.Rexx.space(Compiled Code) (...)
SET JAVA_COMPILER=xxx
The latest versions of NetRexx are available on IBM's WEB site at the following URLs:
http://www.ibm.com/Technology/NetRexx/nrdown.htm USA Server
or at
http://www2.hursley.ibm.com/netrexx/nrdown.htm UK Server
In the following example I assume that you want to install NetRexx in the directory:
~/src/NetRexx
and you've the working Java top tree in:
~/src/java/Java
This is the procedure:
1. Unpack the distribution > cd ~/src/NetRexx > uncompress NetRexx.tar > tar -xvf NetRexx.tar 2. Install the libraries and demo > cd ~/src/java/Java > cp ~/src/NetRexx/nrtools.tar.Z . > uncompress nrtools.tar > tar -xvf nrtools.tar 3. Set the environment variable CLASSPATH You need to add ~/src/java/Java/lib/NetRexxC.zip to the CLASSPATH environment variable This command will depend on your shell (csh, tcsh, ksh ...) > export CLASSPATH=$CLASSPATH:~/src/java/Java/lib/NetRexxC.zip 4. Test the installation > cd ~/src/java/Java/bin > java COM.ibm.netrexx.process.NetRexxC hello > java hello
The following small script might save you some typing
+----------------------------------------------------------------------+ | echo 'java COM.ibm.netrexx.process.NetRexxC' $1 |01 | java COM.ibm.netrexx.process.NetRexxC $1 |02 +----------------------------------------------------------------------+ nrc |
The following recepy (originally provided by Bernhard Hurzeler <behurzeler@ucdavis.edu>) gives some information on how to get MS VJ++ and NetRexx working together.
1. Put the files in their appropriate directories: NetRexxC.zip -> c:\MSDEV\LIB NetRexxC.properties -> c:\MSDEV\LIB NetRexxR.zip -> c:\MSDEV\LIB NetRexxC.bat -> c:\MSDEV\BIN NetRexxC.cmd -> c:\MSDEV\BIN nrc.cmd -> c:\MSDEV\BIN nrc.bat -> c:\MSDEV\BIN 2. Set the CLASSPATH to: c:\Msdev\Lib\NetRexxR.zip;c:\Msdev\Lib\NetRexxC.zip;c:\Msdev\Bin On Windows NT 4.0, you follow the icons Start, Settings, Control Panels, System, Environment tab, System Variable 3. Go to c:\MSDEV\BIN and type the commands: -- generate the java source > jview COM.ibm.netrexx.process.NetRexxC hello -keep nocompile -- compile it > jvc hello.java -- run > jview hello