По-прежнему отображаются ошибки. Вот код
package package1;
import jade.Boot;
import jade.core.AID;
import jade.core.Agent;
import jade.core.Profile;
import static jade.core.Profile.PLATFORM_ID;
import jade.core.ProfileImpl;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAException;
import jade.lang.acl.ACLMessage;
import jade.wrapper.AgentContainer;
import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;
import jade.wrapper.StaleProxyException;
import javax.swing.UIManager;
public class launch extends Agent {
static DFAgentDescription agentDescription;private static AID aid;
static ACLMessage message1, message2;
launch() throws FIPAException{
agentDescription = new DFAgentDescription();
agentDescription.setName(getAID());
DFService.register(this, agentDescription);
DFService.register(this, agentDescription);
}
public static void main(String[] args) throws StaleProxyException {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
try {
String[] arg = { "-gui","ClusteringAgent:multi.agent_clustering.ClusteringAgent" };
Boot.main(arg);
} catch (Exception e) {
e.printStackTrace();
}
jade.core.Runtime rt = jade.core.Runtime.instance(); rt.setCloseVM(true);
String containerName="Mycontainer1";
ProfileImpl pContainer = new ProfileImpl(true);
pContainer.setParameter(Profile.CONTAINER_NAME,containerName);
System.out.println("Launching container "+pContainer);
ContainerController containerRef = rt.createAgentContainer(pContainer);
AgentController Agent = containerRef.createNewAgent("robot" + String.valueOf(1), "package1.launch", new Object[] { 2});
Agent.start();
//create container2
containerName="Mycontainer2";
pContainer = new ProfileImpl( true);
pContainer.setParameter(Profile.CONTAINER_NAME,containerName);
System.out.println("Launching container "+pContainer);
containerRef = rt.createAgentContainer(pContainer);
AgentController Agent1 = containerRef.createNewAgent("robot" + String.valueOf(2), "package1.launch", new Object[] {2});
Agent.start();
}
}
Отображается ошибка:
Exception in thread "main" jade.wrapper.StaleProxyException: Illegal access exception in createAgent() [nested java.lang.IllegalAccessException: Class jade.core.management.AgentManagementService$CommandTargetSink can not access a member of class package1.launch with modifiers ""]
at jade.wrapper.ContainerController.createNewAgent(Unknown Source)