«^»
3.3. What steps are needed to run the above example?


First, you need to compile the interface with JavaIDL's idltojava command.

setenv JAVAIDL_HOME /users/hplives/JavaIDL-1.1EA
setenv PATH $JAVAIDL_HOME/bin:$PATH
idltojava -fclient -fserver -p IDL.Count -j ../.. Count.idl
Because the Count.idl file has a module called CountApp, this command will create a directory called CountApp in which it puts the files that implement the stub and skeleton objects.

Now compile the server program with a JDK 1.0.2 or JDK 1.1.x compiler, e.g.:

setenv CLASSPATH $JAVAIDL_HOME/lib/classes.zip:../..
javac CountServer.java
This javac command will compile CountServant.java and CountServer.java and some of the files in the CountApp directory.

Before running the server, we need to start JavaIDL's Naming Service program. We can do this using JavaIDL's nameserv command:

nameserv -ORBInitialPort 1050 &
This command will produce output like:
Initial Naming Context:
IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436
f6e746578743a312e3000000000010000000000000034000100000000000968657263756c657300
00805e0000001cafabcafe000000023448a50500000000000000080000000000000000
TransientNameServer: setting port for initial object references to: 1050

The server can then be started using a command like:

java IDL.Count.CountServer -ORBInitialPort 1050 &
This should output:
CountServant: constructor called

Finally, compile the client program with a JDK 1.0.2 or JDK 1.1.x compiler:

javac CountClient.java
and run it:
java IDL.Count.CountClient -ORBInitialHost hercules.dur.ac.uk -ORBInitialPort 1050

The client program continually reads in lines from the keyboard. If the line contains the string quit, the client program is terminated; if it contains show, the client program displays the current value of the remote object; otherwise, the client program expects the line to contain an integral value and it instructs the server to set the remote object to this value.