【发布时间】:2019-09-20 16:27:33
【问题描述】:
我在使用 JADE 创建代理时遇到问题。
我的结构
/
Applications
jade
lib
jade.jar
jadeExamples.jar
src
examples
hello
HelloWorldAgent.class
HelloWorldAgent.java
我的档案HelloWorldAgent.java
package examples.hello;
import jade.core.Agent;
public class HelloWorldAgent extends Agent {
protected void setup() {
System.out.println("Hello! My name is "+getLocalName());
}
}
我创建代理的步骤:
-
/Applications/jade/src/examples/hello $ javac *.java -
/Applications/jade/src/examples/hello $ java jade.Boot -gui -agents fred:examples.hello.HelloWorldAgent
我的类路径
/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home:/Applications/jade/lib/jade.jar:/Applications/jade/lib/jadeExamples.jar:/Applications/jade/src/
输出
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.
--------------------------------------------
我的问题
如果我更改 HelloWorldAgent 中的消息(例如 System.out.println("Hello ! My name is "+getLocalName());),则在我运行代理时它不会更新(控制台显示 Hello World! My name is fred)。当我在 hello 文件夹中创建一个新类时,我在 GUI 中找不到我的代理。
我错过了什么?
【问题讨论】:
-
请检查stackoverflow.com/questions/2396493/… 以获取您可以使用的有效类路径设置。您不会将单个
.class文件添加到类路径,而是将目录路径添加到您正在使用的根包层次结构。在您的情况下,它可能是/Applications/jade/src/。 -
@Progman 感谢您的链接,我已经用您所说的修改了我的类路径,但它似乎不起作用
-
请edit您的问题包括您拥有的目录的内容(不确定命令
find .在您的系统上是否可用),您在目录中的文件,您如何开始您正在使用的应用程序和当前类路径设置。根据您的系统,您可能需要在更改环境变量时重新启动系统或启动新终端。也尝试使用-cp参数。包括您从 java 获得的完整完整错误消息。 -
请edit您的问题包含您正在使用的所有目录的详细、完整列表、您在其中的子目录、每个目录包含的文件、
.java的内容文件,用于将.java文件编译成.class文件的语句,执行javac应用程序的位置,CLASSPATH 的当前内容,关于如何启动jade 应用程序的完整语句和完整的完成您收到的错误消息。 -
您应该从您的 CLASSPATH 中删除“jadeExamples.jar”文件(如果您不需要它们)和/或将您的代理移动到不同的包中,这样 JVM 就不会混淆要加载的类(看起来它总是使用 JAR 文件中的
HelloWorldAgent代理)。
标签: java agents-jade