JavaParty Quick Tour

After you have installed JavaParty successfully as described in the section called "Setup", you can test your environment and learn how JavaParty programs are executed by trying out the few steps described below.

The JavaParty environment consists of several standard Java virtual machines that cooperate in executing a parallel JavaParty program. Before you can execute a JavaParty program you must start up the environment. During the environment startup you invoke several regular Java virtual machines on different hosts that should be connected to form the environment.

Write your application

Here we provide a simple example that creates remote objects and invokes methods on them. The main method of class HelloJP creates ten objects and invokes the method hello() on them. This method hello() prints a message to the console window of the virtual machine it is allocated in.

Just copy the source code from this page to a file with the name

package examples;

public remote class HelloJP {
    public void hello() {
        // Print on the console of the virtual machine where the
        // object lives
        System.out.println("Hello JavaParty!");

    public static void main(String[] args) {
        for (int n = 0; n < 10; n++) {
            // Create a remote object on some node
            HelloJP world = new HelloJP();

            // Remotely invoke a method

Compile your application

  1. Create a directory classes where your application classes should be generated to.
mkdir classes
  1. Compile the program
jpc -d classes
  1. Set the class path

JavaParty relies on a distributed file system for loading the classes the application consists of. This is because all components of the environment discussed below need to load the classes of your program. If you do not have a distributed file system, but you would like to execute JavaParty programs in an environment built form multiple computers, you must make sure, you have a consistent copy of your application classes accessible on each machine.

Because the invocation scripts shipped with the JavaParty distribution add the system classes of the JavaParty environment automatically to the class path before actually invoking Java, you only must make sure to have all application classes in your class path.

setenv CLASSPATH classes

Note: You must set the class path in each shell that you will use in the following steps. If you open a new command line window, make sure you set this environment variable before you invoke any JavaParty related commands, otherwise JavaParty will report an error like "exception returned: ClassNotFoundException".

Note: Since the class path specified above is a relative path, you must also make sure, you are in the correct directory.

Unix only: Invite your Java party

Use the following command to create a JavaParty environment and execute your application:

jpinvite examples.HelloJP

Windows only: Start the runtime manager

Within the JavaParty environment one central instance is needed for all participating virtual machines to register themselves. This central instance is called runtime manager. Start the runtime manager by typing:


The command does not terminate until you shut down the JavaParty environment. If the startup of the runtime manager does not work, please refer to the "Trouble Shooting" section.

Windows only: Add virtual machines to your JavaParty environment

The runtime manager is only responsible for coordinating the environment. The remote objects and classes that an application uses reside in a JavaParty virtual machine (jpvm). Before becoming part of the environment the jpvm registers at the runtime manager. You add a new jpvm to your environment by invoking the following command:

jpvm -verbose

Like the runtime manager, the jpvm command does not terminate until the environment is shut down.

The -verbose switch tells the jpvm to output its number assigned by the runtime manager.

You now can repeat this step on some hosts, until you have enough virtual machines added to your system. For testing purpose we suggest to add at least two virtual machines to the environment. If you have only a single computer for testing, you can start multiple virtual machines on the same computer in different processes.

Note: The virtual machine finds the runtime manager automatically by sending a multi-cast request to the network. If that does not work for you or you do not want to use multi-casts, please refer to the "Trouble Shooting" section.

Windows only: Start the JavaParty application

A JavaParty program executes in the distributed environment you have set up so far. During the application startup the runtime manager is contacted and the virtual machines assigned to the environment are inspected. The main class of the application is then invoked on the first virtual machine that has registered. The syntax of invoking a JavaParty program is similar to the syntax invoking a Java program but instead of invoking java you invoke jp and pass the name of the application's main class as first parameter and all arguments that should be passed to the application as further parameters. The class examples.HelloJP does not take any parameters so you simply invoke it by calling:

jp examples.HelloJP

As described above, remote objects are created on your virtual machines an output a message to the corresponding console.

Hello JavaParty!

After this output is displayed (on the terminal where you invoked the first virtual machine) the command immediately returns, but your JavaParty environment is still active and expects the next program to be executed.

If the response of the system is dramatically different from what is described here, although all steps above worked fine, you possibly have not set up your class path correctly for all started components. If that is not the problem, you may also consult the "Trouble Shooting" section.

Windows only: Shut down the environment

To shut down your JavaParty environment you can either kill the runtime manager and all registered virtual machines manually, or invoke the following command that terminates the complete environment silently:


The command name is a shortcut for "JavaParty runtime environment kill". If all the results are similar to ones described here, you are very likely to have a working JavaParty installation and you are ready to try out other Examples or write your own JavaParty programs and compile them. Please refer to the "Comand Line Reference" section to see how to invoke the JavaParty compiler.

Last modified 16 years ago Last modified on Mar 23, 2006 12:40:33 AM