# Need to import lots of lucene libraries to run example code

**URL:** <https://discuss.elastic.co/t/need-to-import-lots-of-lucene-libraries-to-run-example-code/18721>\
**Category:** Elasticsearch\
**Created:** [July 17, 2014, 4:52pm UTC](https://discuss.elastic.co/t/need-to-import-lots-of-lucene-libraries-to-run-example-code/18721 "2014-07-17T16:52:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morris\_Chang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@Morris\_Chang](https://discuss.elastic.co/u/Morris_Chang)\
**Post date:** [July 17, 2014, 4:52pm UTC](https://discuss.elastic.co/t/need-to-import-lots-of-lucene-libraries-to-run-example-code/18721/1 "2014-07-17T16:52:57Z")

</div>

Hi,

I am using java to learn elasticsearch API. I tried to start from the index  
api with the example code on website Resource page:

Node node = nodeBuilder().node();  
Client client = node.client();

```
    IndexResponse response = client.prepareIndex("twitter", "tweet", "1"

```

)  
.setSource(jsonBuilder()  
.startObject()  
.field("user", "kimchy")  
.field("postDate", new Date())  
.field("message", "trying out Elasticsearch"  
)  
.endObject()  
)  
.execute()  
.actionGet();

My problem is that importing only the elasticsearch-1.2.2.jar is not  
enough, and I need to go download .jar files like

org/apache/lucene/search/vectorhighlight/SimpleFieldFragList  
org/apache/lucene/index/memory/MemoryIndex.............

to solve the java.lang.NoClassDefFoundError.

Is there a better efficient way to import all these required class files?  
(instead of google all the jar files and add into eclipse libraries)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 17, 2014, 6:27pm UTC](https://discuss.elastic.co/t/need-to-import-lots-of-lucene-libraries-to-run-example-code/18721/2 "2014-07-17T18:27:52Z")

</div>

Use the Maven dependencies of the ES jar in the Maven repo to let the IDE  
build and run your code.

If you want to run your code, you have to include all jars under the "lib"  
folder in ES\_HOME into your classpath. Maven knows about these dependencies  
automatically.

Jörg

On Thu, Jul 17, 2014 at 6:52 PM, Morris Chang [morrisc1102@gmail.com](mailto:morrisc1102@gmail.com) wrote:

> Hi,
> 
> I am using java to learn elasticsearch API. I tried to start from the  
> index api with the example code on website Resource page:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> IndexResponse response = client.prepareIndex("twitter", "tweet",
> 
> ```
> 
> "1")  
> .setSource(jsonBuilder()  
> .startObject()  
> .field("user", "kimchy")  
> .field("postDate", new Date())  
> .field("message", "trying out  
> Elasticsearch")  
> .endObject()  
> )  
> .execute()  
> .actionGet();
> 
> My problem is that importing only the elasticsearch-1.2.2.jar is not  
> enough, and I need to go download .jar files like
> 
> org/apache/lucene/search/vectorhighlight/SimpleFieldFragList  
> org/apache/lucene/index/memory/MemoryIndex.............
> 
> to solve the java.lang.NoClassDefFoundError.
> 
> Is there a better efficient way to import all these required class files?  
> (instead of google all the jar files and add into eclipse libraries)
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE3cUf\_saJhdPbOisC--2%2BAA6aiJyh3pXdOKBhvsAjdcw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoE3cUf_saJhdPbOisC--2%2BAA6aiJyh3pXdOKBhvsAjdcw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:15am UTC](https://discuss.elastic.co/t/need-to-import-lots-of-lucene-libraries-to-run-example-code/18721/3 "2017-07-06T01:15:07Z")

</div>


