2011年3月11日 星期五

Setup Jade in Linux and Windows

Here is a tutorial about how to setup Java Agent DEvelopment Framework (JADE) in Windows and Linux platform.


This image is directly copied from Jade's homepage.

Agent is a program that may represent a person in computing world. He can move around, interact with other agent. The moving ability means that the agent can travels in computers. The interacting ability means that agent can communicating, making request to others, or accept/reply/reject others. Jade provides platform that agents can live, methods that can help agents move around, and message template to interact with other agent.

The following is how to setup jade platform in Linux and Windows.



Steps in Windows:

We use windows to develop Jade agents, and control agent

1. Download Java JDK.

2. Download Eclipse IDE for Java Developers.

3. Download Jade library.

4. Setup Eclipse, add user library. Note that "migration.jar" is not in Jade's original library. If you needs inter-platform migration, you may download at here.


5. Create a project. Create normal Java project. Remember to add user library by (Add Library→User Library→Jade).



6. New an agent class to the project you created.


7. Add few line to add ability. Following is a sample of mine.

package tw.idv.ctfan.Jade;

import jade.core.Agent;
import jade.core.behaviours.Behaviour;

public class HelloJade extends Agent {
private static final long serialVersionUID = 1L;

protected void setup() {
this.addBehaviour(new SayHelloBehaviour());
}

public class SayHelloBehaviour extends Behaviour {
private static final long serialVersionUID = 1L;
boolean doneYet = false;

@Override
public void action() {
System.out.println("Hello Jade World");
doneYet = true;
}

@Override
public boolean done() {
return doneYet;
}
}
}

8. Setup running configuration.



9. Running Jade platform.


10. Run a Agent. Click on "Main-Container", than click (Actions→Start New Agent).




11. Result.



12. Shutting down window form (File→Shut down Agent Platform). If you did not close it in right way. You may have to re-start eclipse to clean the whole platform process.


Steps in Linux:

In Linux, we use terminal to start agent platform. In Jade, you can't start a platform without GUI, instead, we create a container to a platform

The following is a sample code to start up a container with a main server.
jade.sh
#!/bin/bash

CLASSPATH=.:/home/hadoop/jade/lib/jade.jar:/home/hadoop/jade/lib/commons-codec/commons-codec-1.3.jar:/home/hadoop/ctfan/jade/jar:/home/hadoop/jade/add-ons/migration/lib/migration.jar
export CLASSPATH;

java jade.Boot -host <Your Server IP> -container -container-name hdp001;

Result would like this:



This is the end of this article.

沒有留言:

張貼留言