# Eclipse or tomcat: got an error by trying to create a client

**URL:** <https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653>\
**Category:** Elasticsearch\
**Created:** [June 2, 2016, 7:56am UTC](https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653 "2016-06-02T07:56:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)\
**Post date:** [June 2, 2016, 7:56am UTC](https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653/1 "2016-06-02T07:56:21Z")

</div>

Hello everyone,

I would like to access to my elasticsearch throught eclipse. So, I followed the tutorial [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html) .  
Therefore, I create a class java in my eclipse project:

import java.net.InetAddress;  
import org.elasticsearch.client.Client;  
import org.elasticsearch.client.transport.TransportClient;  
import org.elasticsearch.common.transport.InetSocketTransportAddress;  
public class client {

```
//initialization
private String serverIpAddr = "localhost";
// on startup
Client client = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(serverIpAddr), 9300));
// on shutdown
//client.close();

```

}

I imported the following jar: elasticsearch-2.3.3.jar, joda-time-2.8.jar, lucene-core-5.4.1.jar and guava-19.0.jar. i also included in the root of my eclipse project the file pom.xml (as indicated in the elasticsearch website).

However, i got an error about InetAddress.getByName(serverIpAddr) but there is no suggestion.

Do you have an idea about this problem ? Futhermore, do you have a tutorial more detailed ?

Thank you for your attention and your help.

S

---

<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:** [June 2, 2016, 8:14am UTC](https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653/2 "2016-06-02T08:14:33Z")

</div>

What kind of "error" do you have?

---

<div class="post-metadata">

**Author:** ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)\
**Post date:** [June 2, 2016, 8:48am UTC](https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653/3 "2016-06-02T08:48:26Z")

</div>

Thank you very much for your reply. I got the right answer (it was a stupid error in my side 😛 )

Here is the correction:  
public class client {

```
//initialization
private static String serverIpAddr = "localhost";
// on startup
public static void main(String[] arg) throws UnknownHostException{
Client client = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(serverIpAddr), 9300));

// on shutdown
client.close();
}

```

}

---

<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, 10:46pm UTC](https://discuss.elastic.co/t/eclipse-or-tomcat-got-an-error-by-trying-to-create-a-client/51653/4 "2017-07-05T22:46:57Z")

</div>


