zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McKenzie <mckenzie....@gmail.com>
Subject Re: How to run a simple Java Client
Date Wed, 29 Oct 2014 22:09:10 GMT
Colon is the separate between classpath entries. When you added the
slf4j-log4j jar to the classpath you used a semi colon which is what has
caused the problem.

java -cp "./:zookeeper-3.4.6.jar:./lib/slf4j-log4j12-1.6.1.jar"  ZKClient

ZK relies on a stack of libraries, so you're going to be going through this
process of adding jars to your classpath for a while. It's probably better
to write a wrapper script to run your client that just adds all of the jars
in the lib directory to the JVMs classpath and runs your ZKClient.

On Thu, Oct 30, 2014 at 9:00 AM, Churu Tang <ctang@rubiconproject.com>
wrote:

> Hi Cameron,
>
> Thank you for your explaining! I followed your guide then another error
> occurs.
>
> $ java -cp ./:zookeeper-3.4.6.jar  ZKClient
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/slf4j/LoggerFactory
>         at org.apache.zookeeper.ZooKeeper.<clinit>(ZooKeeper.java:94)
>         at ZKClient.main(ZKClient.java:19)
> Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>         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)
>         ... 2 more
>
> My best guess is that I need to include the ./lib/slf4j-log4j12-1.6.1.jar.
> But again I am having the following java.lang.NoClassDefFoundError Watcher
> error, which I had before.
>
> $ java -cp "./:zookeeper-3.4.6.jar;./lib/slf4j-log4j12-1.6.1.jar"  ZKClient
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/zookeeper/Watcher
> Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.Watcher
>         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: ZKClient. Program will exit.
>
> Also, would you tell me why there is a colon “:” in
> "./:zookeeper-3.4.6.jar”? I try to google but unable to find it. Sorry for
> the naive question. Thanks!
>
>
> Cheers,
> Churu
>
> On Oct 29, 2014, at 2:31 PM, Cameron McKenzie <mckenzie.cam@gmail.com>
> wrote:
>
> > java -cp ./:zookeeper-3.4.6.jar ZKClient
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message