Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03F5D1726C for ; Wed, 29 Oct 2014 22:11:09 +0000 (UTC) Received: (qmail 35968 invoked by uid 500); 29 Oct 2014 22:11:08 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 35924 invoked by uid 500); 29 Oct 2014 22:11:08 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 35911 invoked by uid 99); 29 Oct 2014 22:11:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2014 22:11:07 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mckenzie.cam@gmail.com designates 209.85.215.48 as permitted sender) Received: from [209.85.215.48] (HELO mail-la0-f48.google.com) (209.85.215.48) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2014 22:10:42 +0000 Received: by mail-la0-f48.google.com with SMTP id gq15so3325808lab.21 for ; Wed, 29 Oct 2014 15:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GXcoG0MgRO2gNi7SsICdPI69rKkLA2xLqkSovwotFjQ=; b=OvTxNX0SM6culQHhCuPPevt87Y9Z25SDVL34N7HgRVWet9UIJRZvRmjs6daO/HOA/n 9gEpGMEgOinCa0SNfb9fJO3Xypk0Q2DOp9snkp64GX+GpnLtwINeqKQU9CBfLbnnsPO4 B53j7u+j3Nm2j3Tmum7j2EGSSmSiwIQE2Qw61YWycyoJjrh7Q1XzaEkRtzaFJEAUMSC/ 6geSiFEY7b1zA+TtWvognefDjbxVWdSA6/7rXcFvbmb1MeLn1vNZHs3GWGHNSqMKZfcb ZyGFA+29NPSNKMqB6Oawo7DM0Os/wlv1hYWzZ1AleMDEFkv8Hc0KMW6kFMjBVNzsAcBh EV1A== MIME-Version: 1.0 X-Received: by 10.152.30.9 with SMTP id o9mr14537931lah.8.1414620550876; Wed, 29 Oct 2014 15:09:10 -0700 (PDT) Received: by 10.112.72.170 with HTTP; Wed, 29 Oct 2014 15:09:10 -0700 (PDT) In-Reply-To: <9DE112B5-4E44-4055-AB0C-FC5C99270DA0@rubiconproject.com> References: <7FF845FC-E397-4A08-95CD-B5999551BEF2@rubiconproject.com> <83912909-6D10-41E6-9706-A408644C46A8@rubiconproject.com> <9DE112B5-4E44-4055-AB0C-FC5C99270DA0@rubiconproject.com> Date: Thu, 30 Oct 2014 09:09:10 +1100 Message-ID: Subject: Re: How to run a simple Java Client From: Cameron McKenzie To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=089e0158c7bc6d521b05069703d6 X-Virus-Checked: Checked by ClamAV on apache.org --089e0158c7bc6d521b05069703d6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 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.(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 Watche= r > error, which I had before. > > $ java -cp "./:zookeeper-3.4.6.jar;./lib/slf4j-log4j12-1.6.1.jar" ZKClie= nt > 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 =E2=80=9C:=E2=80=9D in > "./:zookeeper-3.4.6.jar=E2=80=9D? 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 > wrote: > > > java -cp ./:zookeeper-3.4.6.jar ZKClient > > --089e0158c7bc6d521b05069703d6--