我试图运行此示例zookeeper-book-example 我收到此错误
错误:无法找到或加载主类org.apache.zookeeper.book.Master
执行此命令时
java -cp .:/usr/local/zookeeper-3.4.8/zookeeper-3.4.8.jar:/usr/local/slf4j-1.7.2/slf4j-api-1.7.2.jar:/usr/local/slf4j-1.7.2/slf4j-ext-1.7.2.jar:/usr/local/slf4j-1.7.2/slf4j-log4j12-1.7.2.jar:/usr/local/apache-log4j-1.2.17/log4j-1.2.17.jar:/path/to/book/repo/target/ZooKeeper-Book-0.0.1-SNAPSHOT.jar org.apache.zookeeper.book.Master localhost:2181
我正在使用Windows,因此命令将更改为此类
java -cp .:/zookeeper-3.4.9.jar:/lib/slf4j-api-1.6.1.jar:/lib/slf4j-ext-1.6.1.jar:/lib/slf4j-log4j12-1.6.1.jar:/lib/log4j-1.2.16.jar:/zookeeper-book-example-master/target/ZooKeeper-Book-0.0.1-SNAPSHOT.jar: org/apache/zookeeper/book/Master localhost:2181
我从zookeeper目录执行它。
我是否以正确的方式转换命令?我应该从哪里执行命令?以及如何传递现有错误?
答案 0 :(得分:1)
通过从左侧从jar中删除斜杠并用分号替换每个冒号来解决问题,因为这是Windows分隔符
运行命令:
java -cp .;zookeeper-3.4.9.jar;lib/slf4j-api-1.6.1.jar;lib/slf4j-ext-1.6.1.jar;lib/slf4j-log4j12-1.6.1.jar;lib/log4j-1.2.16.jar;zookeeper-book-example-master/target/ZooKeeper-Book-0.0.1-SNAPSHOT.jar; org.apache.zookeeper.book.Master localhost:2181