Tutorials

Jini Example
Jxta Example
Web Services

Related

Jxta
Jini
Web Services

For More Info

From P2P to Web Services and Grids: Peers in a Client/Server World
Ian J. Taylor, 2004
Publisher: Springer
ISBN: 1-85233-869-5

Jxta Tutorial

This tutorial provides a simple introduction to Jxta by illustrating three simple Jxta applications, with the option of writing a P2P chat application.  You will need to refer to the notes on the Jxta Configurator for configuring your peer. There are three programming examples:

  1. A Simple example that starts the Jxta platform (notes)
  2. An example that uses the Jxta Discovery mechanism to discover Jxta peers on the network (notes).
  3. A example illustrating how you would go a bout creating a pipe (notes)
  4. Exercise: Have a go at trying to extend example 3 to create a one-to-one chat program

To Run Jxta applications, you need the Jxta jar files for the core platform. These are available from here or on the Jxta web site, given below.

I strongly recommend that you note these address and use the on-line JAVADOC Jxta documentation wherever possible

Obtaining the Source Code

There are three Options:

  • Possibly, the easiest thing to do is to download the self-contained zip file here. Simple unzip this into a directory and everything should work straight off.
  • Download the source files without the Java Jxta Jar files here. However, you will need to edit the batch files to make them point to the location of your Jxta Jar files. 
  • Or the source code can be browsed on-line and is located here. 

Within this directory you have the following files:

Java Files

  • StartJxta.java (notes)
  • DiscoverPeers.java (notes)
  • PipeExample.java (notes)
  • PipeListener.java (same as PipeExample notes)

Build/Execution Files

  • build.bat – File for compile ALL the examples Windows OS only
  • run1.bat – File for running example 1
  • run2.bat – File for running example 2
  • run3.bat – File for running example 3

 

Resources

 

  • pipexample.adv – the XML pipe advert for the pipe example

Libraries

  • Lib - in the lib directory, all of the necessary Java files that are needed for compilation and execution are stored.  You can use these or use others directly from http://www.Jxta.org/ or ones stored locally at CS in Cardiff. See Lab Supervisor for location of these. The following JAR files are needed in your classpath:
  •  Jxta.jar – core Jxta platform
  •  log4j.jar – Jxta logging
  •  Jxtasecurity.jar – basic Jxta security
  •  cryptix32.jar - cryptography
  •  cryptix-asn1.jar - cryptography
  •  minimalBC.jar – bouncy castle
  •  Jxtaptls.jar

IntelliJ Project files

  • ComSc.ipr
  • ComSc.iws

Notes on the Batch Files: Using Other Libraries

To use a different path for the libraries, you need to edit all 4 batch files, build.bat, run1.bat, run2.bat, run3.bat, run4.bat. You need to alter the location specified by the LIB_DIR environment variable. For example:

set LIB_DIR=lib
java -classpath .\;%LIB_DIR%\Jxta.jar;%LIB_DIR%\log4j.jar;
%LIB_DIR%\Jxtasecurity.jar;%LIB_DIR%\Jxtaptls.jar;
%LIB_DIR%\minimalBC.jar;%LIB_DIR%\cryptix32.jar;
%LIB_DIR%\cryptix-asn1.jar StartJxta

To update, change the LIB_DIR line to the new location. For example is the libs were in G:\Jxta_Demo\IJTlib then you would change it as follows:

set LIB_DIR=G:\Jxta_Demo\IJTlib
java -classpath .\;%LIB_DIR%\Jxta.jar;%LIB_DIR%\log4j.jar;
%LIB_DIR%\Jxtasecurity.jar;%LIB_DIR%\Jxtaptls.jar;
%LIB_DIR%\minimalBC.jar;%LIB_DIR%\cryptix32.jar;
%LIB_DIR%\cryptix-asn1.jar StartJxta