在过去的几天里,我一直在努力掌握 AKKA 和我得到的 Actor 模型,我通过消息等进行交流,但如果我能得到一个简单的 HelloWorld 项目来编译,那我就完蛋了。这是单个 helloWorld.java 文件...我在这里包含了两个类(Actor)...
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.ActorRef;
public class helloWorld extends UntypedActor {
@Override
public void preStart() {
// create the greeter actor
final ActorRef greeter =
getContext().actorOf(Props.create(Greeter.class), "greeter");
// tell it to perform the greeting
greeter.tell(Greeter.Msg.GREET, getSelf());
}
@Override
public void onReceive(Object msg) {
if (msg == Greeter.Msg.DONE) {
// when the greeter is done, stop this actor and with it the application
getContext().stop(getSelf());
} else unhandled(msg);
}
}
public class Greeter extends UntypedActor {
public static enum Msg {
GREET, DONE;
}
@Override
public void onReceive(Object msg) {
if (msg == Msg.GREET) {
System.out.println("Hello World!");
getSender().tell(Msg.DONE, getSelf());
} else unhandled(msg);
}
}
这是我在终端(Ubunut)中使用的命令......
java -classpath $AKKA_HOME/lib/scala-library.jar:$AKKA_HOME/lib/akka/akka-actor_2.10-2.2.1.jar:$AKKA_HOME/lib/akka/config-1.0.2.jar akka.Main helloWorld
这是我得到的例外......
Exception in thread "main" java.lang.ClassNotFoundException: helloWorld
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:67)
at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:66)
at scala.util.Try$.apply(Try.scala:161)
at akka.actor.ReflectiveDynamicAccess.getClassFor(DynamicAccess.scala:66)
at akka.Main$.main(Main.scala:32)
at akka.Main.main(Main.scala)
任何人都可以提供任何建议吗?
提前致谢