I have created a simple 💬 Chat Messenger using networking libraries of Java. For the front end I have used JFrame class of Swing.
I have set it to local host, you can set it to the Host's public IP if you want.
import javax.swing.JFrame;
public class ClientTest {
public static void main(String args[]){
Client cl=new Client("127.0.0.1");
cl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cl.startRunning();
}
}
On Server Machine:
javac TestServer.java
On Client Machine:
javac ClientTest.java
On Server Machine:
java TestServer
You will have server window opened which starts listening for connections on port 1234.
On Client Machine:
java ClientTest
Connection will be established if no error is thrown and client window will popup. Communication can be done now!