How do you create a REST client for Java?

This is an old question (2008) so there are many more options now than there were then: Apache CXF has three different REST Client options Jersey (mentioned above). Spring RestTemplate superceded by Spring WebClient Commons HTTP Client build your own for older Java projects. UPDATES (projects still active in 2020): Apache HTTP Components (4.2) Fluent … Read more

Exception in thread “main” java.net.ConnectException: Connection refused: connect Socket Programming Java

There are 2 issues in your program: You use the port 80 which is part of the well-known ports or system ports (0 to 1023), so you need to launch your server with the admin rights or change it for 8080 for example. You forgot to call bw.newLine() after each bw.write(sendMessage) such that it waits for ever since on the other side you call br.readLine() which means that it … Read more