# CrossTeamHello: A client/server Hello World

The ability to create new teams means we can experiment with sharing objects via cross-team pointers. This example implements a client/server HelloWorld using the HelloBackEnd.java class to export an object from the kernel and the HelloHandle.java class to import that object into the current team. These classes make use of the Exportable and Importable system classes which manage references into other teams, and, if one of the participating teams dies or is being naughty, allow us to revoke the references.

      tservo@satolove tutorial> jikes -classpath <install dir>/share/kaffe/JanosVM.jar HelloBackEnd.java
      tservo@satolove tutorial> jikes -classpath <install dir>/share/kaffe/JanosVM.jar HelloHandle.java

Now, start up the VM and run HelloBackEnd in the kernel to export the server object.

    [Terminal 1]
      tservo@satolove tutorial> janosvm -config tutorial.config -name janosvm \
        -jsitcpport 14000 -noexit

    [Terminal 2]
      tservo@satolove tutorial> jsihey janosvm execute run of team 1 with class \
        HelloBackEnd then nothing

Let's divert our attention for a second to the tutorial.config file because it's working some magic required for all this to work. The major part of the config file defines which classes are to be exported from the kernel and imported by the other teams, so basically it's defining which classes should be shared amongst all the teams. Near the bottom you might've notice that HelloBackEnd is listed as one of the exports. The export is needed because any teams that import a HelloBackEnd object are going to do a cast from Object to HelloBackEnd so they'll need the same class. If this export wasn't there a different HelloBackEnd class will be loaded by each team and the cast won't work so we won't be able to use the object. So let's try this out and see if everything works:

    [Terminal 2]
      tservo@satolove tutorial> jsihey janosvm create team with name "hello-client"
        then print "%(result:d)\n"
      2
      tservo@satolove tutorial> jsihey janosvm execute run of team 2 with class
        HelloHandle then nothing

    [Terminal 1]
      Client hello-client says `Hello World'

Cool. Now, shutdown the VM and go to the next section, or if you're adventurous remove HelloBackEnd from the config file, restart the VM, and run everything again.

Copyright (c) 2000, 2001 The University of Utah and the Flux Group.
All rights reserved.
Permission to use, copy, modify, distribute, and sell this documentation for any purpose is hereby granted without fee, provided that the above copyright notice(s) appear in all copies.