0

I can't deploy the agent in JADE implemented in Java, any alternatives ?

package package1;

import jade.core.Agent;

public class JadePFE extends Agent {
    @Override
    protected void setup() {
        System.out.println("Hello agent 007");
    }

}
timaschew
  • 16,254
  • 6
  • 61
  • 78
zehari
  • 3
  • 2

2 Answers2

1

I think you mean to start the JADE platform, this is the contents of the my main method which launches the whole thing. Hope it helps

public class main {
public static void main(String[] args) {
    // TODO Auto-generated method stub
    String[] args1 = new String[3];
    args1[0] = "-gui";
    args1[1] = "-agents";
    args1[2] = "agentName:package.agentClassName";
    jade.Boot.main(args1);  

}

}

Just_Alex
  • 518
  • 1
  • 4
  • 16
0

If I have understand, you want know how deploy an agent (and maybe start the platform) directly from the code.

I show you how:

import jade.core.Runtime;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.*;

public class Start {

    public static void main(String args[]) throws InterruptedException, StaleProxyException {

        // Get a hold on JADE runtime
        Runtime runTime = Runtime.instance();

        // Exit the JVM when there are no more containers around
        runTime.setCloseVM(true);

        // Create a profile and the main container and start RMA
        Profile mainProfile = new ProfileImpl(true);
        AgentContainer mainContainer = runTime.createMainContainer(mainProfile);
        AgentController rma = mainContainer.createNewAgent("rma", "jade.tools.rma.rma", null);
        rma.start();
        Thread.sleep(500);

        // Create a Sniffer
        AgentController sniffer = mainContainer.createNewAgent(
                "mySniffer", "jade.tools.sniffer.Sniffer",
                new Object[]{"BuyerAgent1;BuyerAgent2;ShipperAgent1;ShipperAgent2"});
        sniffer.start();
        Thread.sleep(500);

        // Create a Introspector
        AgentController introspector = mainContainer.createNewAgent(
                "myIntrospector", "jade.tools.introspector.Introspector",
                null);
        introspector.start();
        Thread.sleep(500);

        // Prepare for create and fire new agents:
        Profile anotherProfile;
        AgentContainer anotherContainer;
        AgentController agent;

        /*  Create a new profile and a new non-main container, connecting to the
            default main container (i.e. on this host, port 1099)
            NB. Two containers CAN'T share the same Profile object: create a new one. */

        anotherProfile = new ProfileImpl(false);
        anotherContainer = runTime.createAgentContainer(anotherProfile);
        System.out.println("Starting up a BuyerAgent...");
        agent = anotherContainer.createNewAgent("BuyerAgent1", "transfersimulation.BuyerAgent", new Object[0]);
        agent.start();
        Thread.sleep(900);

        anotherProfile = new ProfileImpl(false);
        anotherContainer = runTime.createAgentContainer(anotherProfile);
        System.out.println("Starting up a BuyerAgent...");
        agent = anotherContainer.createNewAgent("BuyerAgent2", "transfersimulation.BuyerAgent", new Object[0]);
        agent.start();
        Thread.sleep(900);

        anotherProfile = new ProfileImpl(false);
        anotherContainer = runTime.createAgentContainer(anotherProfile);
        System.out.println("Starting up a ShipperAgent...");
        agent = anotherContainer.createNewAgent("ShipperAgent1", "transfersimulation.ShipperAgent", new Object[0]);
        agent.start();
        Thread.sleep(900);

        return;
    }
}

This works if no other JADE Platform is already running.

Gioce90
  • 554
  • 2
  • 10
  • 31