我希望使用 Akka actor 模块。 我在 Kubuntu 中使用 Eclipse。 我从 akka 网站下载了 .zip 存档,转到:
Project->Properties->Java Build Path->Libraries->Add External Jar
并添加了 zip 附带的所有 jar。
在我的代码中,我这样做:
import akka.actor.Actor;
import akka.event.EventHandler;
class MyActor extends Actor{
}
我得到了一个直接错误:
class myActor extends Actor{
错误是:
The type Actor cannot be the superclass of MyActor; a superclass must be a class
但是 Actor 不应该是一个类吗?至少所有教程都是这么说的。
最佳答案
尝试使用akka.actor.UntypedActor
。来自 reference documentation :
Actor in Java are implemented by extending the UntypedActor class and implementing the onReceive method. This method takes the message as a parameter.
这是一个示例:https://github.com/alexaverbuch/akka_chat_java/blob/master/src/main/java/chat/actors/Session.java
关于java - 在 Eclipse (Kubuntu) 中安装 Akka for Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13682099/