Arduino Ethernetshield

simple Arduino TCP Server using the Ethernetshield and a Java Client

In my previous post I was using the Arduino Ethernetshield to connect my Arduino to a Java Server running on my local machine. Now I’m Using the Arduino as a TCP Server and my local machine as a Client. So it’s just the other way around ;)

I modified the Arduino Webserver example to a simple TCP Server:

To connect to this Server I’m using a simple Java TCP Client.

Change the IP Adress to make it work in your local Network (in the Arduino AND the Java Code). Then

  1. compile and upload the code to the arduino. The Server should be starting (check the Serial Monitor)
  2. Afterwards compile and start the Java Client.
  3. If it connects correctly to the Arduino it will send the message: “Hello Arduino Server”.
  4. The Arduino-Server recieves this message and will send it back: “You said: Hello Arduino Server”.


This is just a very simple example to get started with the Arduino Ethernetshield. You should also check out my similar Post to use the Arduino as a TCP Client.

2 thoughts on “simple Arduino TCP Server using the Ethernetshield and a Java Client

  1. ni

    Im getting this exception here >> in and also on eclipse IDE

    Exception in thread “main” java.lang.NoClassDefFoundError: Program
    Caused by: java.lang.ClassNotFoundException: Program
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    Could not find the main class: Program. Program will exit.

    what to do ? do you have a .exe of the applicaiton

  2. Pedro Manuel

    Hello, my name is Pedro Manuel and I am delighted to meet these great tutorials. First I would like to apologize for my English, I’m Spanish and I have a very low level of English, sorry.

    I’m developing a Java application able to connect to the arduino TCP girders. Java-arduino communication I have it resolved, the problem I have is when you want to communicate with the arduino java client.
    To receive information arduino first I have to send a command from java requesting information. I would like to know how it could be done for the arduino is able to communicate with the java client without sending the information request command. To do this I created a Java application that is client and server at a time, and in like manner the arduino. This presents a major hassle and I do not think it is necessary to cough.
    Could you tell me how the Java client can be aware of the arrival of information arduino?

    Like I said earlier, I am developing application consists of a client like the mentoring process and a thread, run the server capable of serving the packets of information that the arduino sends. I’m having a lot of problems with this project and would like to know your opinion. Do you need all this, what could be done differently?

    I leave you my email if you could contact me or answer me on my blog, I am a faithful follower of the.

    One last thing, what happened to the blog that’s been dropped a few days?, I thought you left and that made ​​me sad.

    A greeting.


Leave a Reply

Your email address will not be published. Required fields are marked *

7 × eight =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">