Getting error while building simple maven based java application with couchbase

Hi Every one,

I am new to couchbase and was trying to use hello world application with java sdk for couchbase .

I have added dependency in pom.xml


 <dependency>
    <groupId>com.couchbase.client</groupId>
    <artifactId>java-client</artifactId>
    <version>2.4.3</version>
  </dependency>

source code :slight_smile:

package com.upscouchbase.app;
import com.couchbase.client.java.*;
import com.couchbase.client.java.document.*;
import com.couchbase.client.java.document.json.*;
import com.couchbase.client.java.query.*;


/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	// Create a cluster reference
    /*	CouchbaseCluster cluster = CouchbaseCluster.create("127.0.0.1");

    	// Connect to the bucket and open it
    	Bucket bucket = cluster.openBucket("default");

    	// Create a JSON document and store it with the ID "helloworld"
    	JsonObject content = JsonObject.create().put("hello", "world");
    	JsonDocument inserted = bucket.upsert(JsonDocument.create("helloworld", content));

    	// Read the document and print the "hello" field
    	JsonDocument found = bucket.get("helloworld");
    	System.out.println("Couchbase is the best database in the " + found.content().getString("hello"));

    	// Close all buckets and disconnect
    	cluster.disconnect(); */
    	
    	Cluster cluster = CouchbaseCluster.create("localhost");
        Bucket bucket = cluster.openBucket("default");

        // Create a JSON Document
        JsonObject arthur = JsonObject.create()
            .put("name", "Arthur")
            .put("email", "kingarthur@couchbase.com")
            .put("interests", JsonArray.from("Holy Grail", "African Swallows"));

        // Store the Document
        bucket.upsert(JsonDocument.create("u:king_arthur", arthur));

        // Load the Document and print it
        // Prints Content and Metadata of the stored Document
        System.out.println(bucket.get("u:king_arthur"));

        // Create a N1QL Primary Index (but ignore if it exists)
        bucket.bucketManager().createN1qlPrimaryIndex(true, false);

        // Perform a N1QL Query
        N1qlQueryResult result = bucket.query(
            N1qlQuery.parameterized("SELECT name FROM default WHERE $1 IN interests",
            JsonArray.from("African Swallows"))
        );

        // Print each found Row
        for (N1qlQueryRow row : result) {
            // Prints {"name":"Arthur"}
            System.out.println(row);
        }
    	
    	//System.out.println( "Hello World!" );
    }
}

while running i am getting below error :

Exception in thread "main" java.lang.NoClassDefFoundError: com/couchbase/client/
java/Cluster
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.couchbase.client.java.Cluster
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more

Looks like your classpath is still wrong, there must be something misconfigured when running the app. The Cluster interface for sure is part of java-client.