我为Cassandra提供了Hector库的简单示例:https://github.com/zznate/cassandra-tutorial/tree/master/src/main/java/com/datastax/tutorial 编译成功了。 但是我无法运行它:
root@ns38:/home/marcin/work/java/jctserv/hector-core-1.0-3# javac -cp cassandra-thrift-1.0.6.jar:FastInfoset-1.2.2.jar:slf4j-api-1.6.1.jar:uuid-3.2.0.jar:commons-lang-2.4.jar:guava-r09.jar:speed4j-0.9.jar:commons-pool-1.5.3.jar:hector-core-1.0-3.jar InsertRowsForColumnFamilies.java TutorialCommand.java root@ns38:/home/marcin/work/java/jctserv/hector-core-1.0-3# java InsertRowsForColumnFamilies Exception in thread "main" java.lang.NoClassDefFoundError: InsertRowsForColumnFamilies (wrong name: com/datastax/tutorial/InsertRowsForColumnFamilies) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: InsertRowsForColumnFamilies. Program will exit. root@ns38:/home/marcin/work/java/jctserv/hector-core-1.0-3#
我做错了什么? 感谢。
答案 0 :(得分:3)
您需要根据提到的包将类文件放在适当的文件夹中,然后使用classpath和完全限定的类名调用Java。见http://www.cs.usfca.edu/~parrt/course/601/lectures/java.tools.html
尝试:
java -cp cassandra-thrift-1.0.6.jar:FastInfoset-1.2.2.jar:slf4j-api-1.6.1.jar:uuid-3.2.0.jar:commons-lang-2.4.jar:guava-r09.jar:speed4j-0.9.jar:commons-pool-1.5.3.jar:hector-core-1.0-3.jar com.datastax.tutorial.InsertRowsForColumnFamilies
答案 1 :(得分:1)
试试这个
java com.datastax.tutorial.InsertRowsForColumnFamilies