This example provides a simple demonstration of how to use a JavaSpace (it is not Blitz specific).
.jar
's:
jsk-lib.jar, jsk-platform.jar from the JINI 2.x distribution.
/jini2_1
and your Blitz distribution is in /blitz
, you can compile the example as follows:
cd /blitz/examples/helloworld javac -classpath /jini2_1/lib/jsk-lib.jar:/jini2_1/lib/jsk-platform.jar *.java
Before starting the example, ensure that you have a Blitz instance running in a public lookup group - see the Installation Guide. This is necessary because the Lookup
class does a single lookup and discover step - it does not register with discovered lookup services. Thus, if a Blitz instance isn't registered beforehand, it will not be found (I'll fix this in a future release!).
We are now ready to run the example. First, we'll start the taker - open a new terminal window and then:
cd /blitz java -Djava.security.policy=config/policy.all -classpath /jini2_1/lib/jsk-lib.jar:/jini2_1/lib/jsk-platform.jar:/blitz/examples/ helloworld.TakerNow we'll run the Writer - open a new terminal window and then:
cd /blitz java -Djava.security.policy=config/policy.all -classpath /jini2_1/lib/jsk-lib.jar:/jini2_1/lib/jsk-platform.jar:/blitz/examples/ helloworld.Writer
The Taker will exit automatically when it hasn't taken an Entry in the last 60 seconds.
For more examples see:
For JavaSpaces resources see here