我一直未能运行使用 Voldemort 的 Java 应用程序。我正在尝试运行可以通过 Voldemort 下载找到的客户端示例。
我编译代码如下:javac -classpath voldemort-0.96.jar ClientExample.java
没有出现错误。但是当我尝试按如下方式运行代码时:java -classpath voldemort-0.96.jar ClientExample
我收到以下错误消息:
Exception in thread "main" java.lang.NoClassDefFoundError: ClientExample
Caused by: java.lang.ClassNotFoundException: ClientExample
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: ClientExample. Program will exit.
我不确定我做错了什么。伏地魔罐子在同一个文件夹中。
编辑:这是 ClientExample 代码
package voldemort.examples;
import voldemort.client.ClientConfig;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClient;
import voldemort.client.StoreClientFactory;
import voldemort.versioning.Versioned;
public class ClientExample {
public static void main(String[] args) {
String bootstrapUrl = "tcp://localhost:6666";
StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
StoreClient<String, String> client = factory.getStoreClient("my_store_name");
Versioned<String> version = client.get("some_key");
version.setObject("new_value");
client.put("some_key", version);
}
}