# Error while using the Java API

**URL:** <https://discuss.elastic.co/t/error-while-using-the-java-api/35673>\
**Category:** Elasticsearch\
**Created:** [November 26, 2015, 1:30pm UTC](https://discuss.elastic.co/t/error-while-using-the-java-api/35673 "2015-11-26T13:30:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)\
**Post date:** [November 26, 2015, 1:30pm UTC](https://discuss.elastic.co/t/error-while-using-the-java-api/35673/1 "2015-11-26T13:30:07Z")

</div>

I started a new Java project. I'm using the elasticsearch-2.0.0.jar file, included it in my project, and the guava-18.0.jar file. I did not do any other configurations.

I'm using Elasticsearch 2.0.0 and it is running on localhost port 9200. The following is my Java code, all I'm trying to do is create a client:

```
  public void createClient(String Username) throws UnknownHostException {
           Client client = TransportClient.builder().build()
                          .addTransportAddress(new InetSocketTransportAddress(InetAddress.getLocalHost(), 9200))
                          .addTransportAddress(new InetSocketTransportAddress(InetAddress.getLocalHost(), 9200));

}

```

However, it is giving me the following error:

```
 Nov 26, 2015 2:39:42 PM org.elasticsearch.plugins.PluginsService <init>
 INFO: [Hydro] loaded [], sites []
 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/util/Version
     at org.elasticsearch.Version.<clinit>(Version.java:44)
     at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:117)
     ......
 Caused by: java.lang.ClassNotFoundException: org.apache.lucene.util.Version
     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
     ... 4 more
 Java Result: 1

```

I prefer using a Java project and not a Maven project because I dont have any experience with Maven. Please let me know which jar files that I need??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 26, 2015, 1:53pm UTC](https://discuss.elastic.co/t/error-while-using-the-java-api/35673/2 "2015-11-26T13:53:52Z")

</div>

@Israaaaa here is what `mvn dependency:tree` gives on the 2.0.0 project (I removed test scoped libs):

```auto
[INFO] org.elasticsearch:elasticsearch:jar:2.0.0
[INFO] +- org.apache.lucene:lucene-core:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-backward-codecs:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-analyzers-common:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-queries:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-memory:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-highlighter:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-queryparser:jar:5.2.1:compile
[INFO] | \- org.apache.lucene:lucene-sandbox:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-suggest:jar:5.2.1:compile
[INFO] | \- org.apache.lucene:lucene-misc:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-join:jar:5.2.1:compile
[INFO] | \- org.apache.lucene:lucene-grouping:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-spatial:jar:5.2.1:compile
[INFO] +- org.apache.lucene:lucene-expressions:jar:5.2.1:compile
[INFO] | +- org.antlr:antlr-runtime:jar:3.5:compile
[INFO] | +- org.ow2.asm:asm:jar:4.1:compile
[INFO] | \- org.ow2.asm:asm-commons:jar:4.1:compile
[INFO] +- com.spatial4j:spatial4j:jar:0.4.1:compile
[INFO] +- com.vividsolutions:jts:jar:1.13:compile
[INFO] +- com.github.spullara.mustache.java:compiler:jar:0.8.13:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] +- joda-time:joda-time:jar:2.8.2:compile
[INFO] +- org.joda:joda-convert:jar:1.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.5.3:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.5.3:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.5.3:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.12:compile
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.5.3:compile
[INFO] +- io.netty:netty:jar:3.10.5.Final:compile
[INFO] +- com.ning:compress-lzf:jar:1.0.2:compile
[INFO] +- com.tdunning:t-digest:jar:3.0:compile
[INFO] +- org.hdrhistogram:HdrHistogram:jar:2.1.6:compile
[INFO] +- commons-cli:commons-cli:jar:1.3.1:compile
[INFO] +- org.codehaus.groovy:groovy-all:jar:indy:2.4.4:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- log4j:apache-log4j-extras:jar:1.2.17:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.2:compile
[INFO] +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] \- com.twitter:jsr166e:jar:1.1.0:compile

```

Good luck for adding that manually!

---

<div class="post-metadata">

**Author:** ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)\
**Post date:** [November 26, 2015, 2:47pm UTC](https://discuss.elastic.co/t/error-while-using-the-java-api/35673/5 "2015-11-26T14:47:51Z")

</div>

LOL Done! THANK YOU!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:35pm UTC](https://discuss.elastic.co/t/error-while-using-the-java-api/35673/6 "2017-07-05T23:35:35Z")

</div>


