Java 在JADE中创建代理

Java 在JADE中创建代理,java,agents-jade,Java,Agents Jade,我无法用JADE创建代理 我的结构 我的文件HelloWorldAgent.java package examples.hello; 进口玉石、芯材、代理; 公共类HelloWorldAgent扩展了代理{ 受保护的无效设置(){ System.out.println(“你好!我的名字是”+getLocalName()); } } 我按照以下步骤创建代理: /Applications/jade/src/examples/hello$javac*.java /Applications/jade

我无法用JADE创建代理

我的结构 我的文件
HelloWorldAgent.java
package examples.hello;
进口玉石、芯材、代理;
公共类HelloWorldAgent扩展了代理{
受保护的无效设置(){
System.out.println(“你好!我的名字是”+getLocalName());
}
}
我按照以下步骤创建代理:
  • /Applications/jade/src/examples/hello$javac*.java

  • /Applications/jade/src/examples/hello$javajade.Boot-gui-agents弗雷德:examples.hello.HelloWorldAgent

  • Myclasspath
    /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home:/Applications/jade/lib/jade.jar:/Applications/jade/lib/jadeExamples.jar:/Applications/jade/src/

    输出
    2019年9月21日下午5:28:05 jade.core.Runtime beginContainer
    信息:----------------------------------
    这是JADE 4.5.0-2017年5月23日第6825版10:06:04
    在LGPL限制下以开源方式下载,
    在http://jade.tilab.com/
    ----------------------------------------
    2019年9月21日下午5:28:05 jade.imtp.leap.leappimtpmanager初始化
    信息:侦听地址上的平台内命令:
    - jicp://192.168.1.104:1099
    2019年9月21日下午5:28:06 jade.core.BaseService init
    信息:服务jade.core.management.AgentManagement已初始化
    2019年9月21日下午5:28:06 jade.core.BaseService init
    信息:服务jade.core.messaging.messaging已初始化
    2019年9月21日下午5:28:06 jade.core.BaseService init
    信息:服务jade.core.resource.ResourceManagement已初始化
    2019年9月21日下午5:28:06 jade.core.BaseService init
    信息:服务jade.core.mobility.AgentMobility已初始化
    2019年9月21日下午5:28:06 jade.core.BaseService init
    信息:服务jade.core.event.Notification已初始化
    2019年9月21日下午5:28:11 jade.mtp.http.HTTPServer
    信息:HTTP-MTP使用XML解析器com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    2019年9月21日下午5:28:11 jade.core.messaging.MessagingService启动
    信息:MTP地址:
    http://192.168.1.104:7778/acc
    你好,世界!我叫弗雷德
    2019年9月21日下午5:28:11 jade.core.AgentContainerImpl平台
    信息:--------------------------------------
    代理容器总管-Container@192.168.1.104准备好了。
    --------------------------------------------
    
    我的问题 如果我更改HelloWorldAgent中的消息(例如,
    System.out.println(“你好!我的名字是”+getLocalName());
    ),当我运行我的代理时,它不会更新(控制台显示
    Hello World!我的名字是fred
    )。当我在hello文件夹中创建一个新类时,我在GUI中找不到我的代理


    我错过了什么?

    您没有正确设置类路径。如中所述,类路径可以包含两种条目类型:

    因此,类路径包含:

    • JAR文件,以及
    • 到包层次结构顶部的路径
    在您的情况下,您只能引用以下
    .jar
    文件:

    • /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
    • /Applications/jade/lib/jade.jar
    • /Applications/jade/lib/jadeExamples.jar
    请注意,您的工作路径
    /Applications/jade/src/examples/hello/
    不在类路径中。这意味着您的自定义jade类不可见/不可访问

    为了解决您的问题,您必须添加您想要在类路径中使用的其他路径。通常,您使用目录
    来表示希望类路径中有“当前目录”


    请记住,您的类路径中有JAR文件
    jadeExamples.JAR
    。当您为更改后的
    HelloWorldAgent
    类拥有
    .class
    文件时,可能不清楚JVM正在加载哪个类,是JAR文件中的类还是文件系统中的
    .class
    文件中的类。不要在类路径中为同一个类提供两次相同的包,甚至不要用新的更改过的jar文件更改
    jadeExamples.jar
    文件(这可能会更加混乱)。相反,在包/命名空间/目录中创建一个新代理并加载它
    -agents foobar:YOUR.package.and.ClassName
    ,但请确保类路径设置正确。

    请检查可使用的有效类路径设置。您不会将单个
    .class
    文件添加到类路径中,而是将目录路径添加到正在使用的根包层次结构中。在您的情况下,它可能是
    /Applications/jade/src/
    @Progman感谢您的链接,我已经用您所说的内容修改了我的类路径,但似乎不起作用。请您提问,包括您拥有的目录的内容(不确定您的系统上是否有
    find.
    命令)、目录中的文件,如何启动应用程序以及当前使用的类路径设置。根据您的系统,在更改环境变量时,您可能需要重新启动系统或启动新的终端。同时尝试使用
    -cp
    参数。包括您从java获得的完整错误消息。请在问题中包含您正在使用的所有目录、其中的子目录、每个目录的文件、
    .java
    文件的内容的详细完整列表,用于将
    .java
    文件编译为
    .class
    文件的语句、执行
    javac
    应用程序的位置、类路径的当前内容、关于如何启动jade应用程序的完整语句以及收到的完整错误消息。您应该删除“jadeExamples.jar”文件(如果不需要的话)和/或将代理移动到另一个包中,这样JVM就不会混淆要加载哪个类(看起来它总是使用jar文件中的
    HelloWorldAgent
    代理)。非常感谢您提供的详细信息
    /
      Applications
        jade
          lib
            jade.jar
            jadeExamples.jar
          src
            examples
              hello
                HelloWorldAgent.class
                HelloWorldAgent.java
    
    Sep 21, 2019 5:28:05 PM jade.core.Runtime beginContainer
    INFO: ----------------------------------
        This is JADE 4.5.0 - revision 6825 of 23-05-2017 10:06:04
        downloaded in Open Source, under LGPL restrictions,
        at http://jade.tilab.com/
    ----------------------------------------
    Sep 21, 2019 5:28:05 PM jade.imtp.leap.LEAPIMTPManager initialize
    INFO: Listening for intra-platform commands on address:
    - jicp://192.168.1.104:1099
    
    Sep 21, 2019 5:28:06 PM jade.core.BaseService init
    INFO: Service jade.core.management.AgentManagement initialized
    Sep 21, 2019 5:28:06 PM jade.core.BaseService init
    INFO: Service jade.core.messaging.Messaging initialized
    Sep 21, 2019 5:28:06 PM jade.core.BaseService init
    INFO: Service jade.core.resource.ResourceManagement initialized
    Sep 21, 2019 5:28:06 PM jade.core.BaseService init
    INFO: Service jade.core.mobility.AgentMobility initialized
    Sep 21, 2019 5:28:06 PM jade.core.BaseService init
    INFO: Service jade.core.event.Notification initialized
    Sep 21, 2019 5:28:11 PM jade.mtp.http.HTTPServer <init>
    INFO: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    Sep 21, 2019 5:28:11 PM jade.core.messaging.MessagingService boot
    INFO: MTP addresses:
    http://192.168.1.104:7778/acc
    Hello World! My name is fred
    Sep 21, 2019 5:28:11 PM jade.core.AgentContainerImpl joinPlatform
    INFO: --------------------------------------
    Agent container Main-Container@192.168.1.104 is ready.
    --------------------------------------------