chat client in java

vinci

vinci

@vinci-e4PtMU Oct 11, 2024
I want to develop a simple chat client in java and doesnt know where to begin from .i just know threading concepts amnd core java only but have capability to build so. Any help is welcome here.I just want to the steps to build a chat client software in java with eclipse and netbeans

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • simplycoder

    simplycoder

    @simplycoder-NsBEdD Sep 30, 2011

    @vinci : You should have a good understanding of JMF(Java Media Framework). I believe that there were discussions on this on CE some time ago, just search for JMF on this board and hopefully you can find it.
    Go through this link as well.
    <a href="https://en.wikipedia.org/wiki/Java_Media_Framework" target="_blank" rel="nofollow noopener noreferrer">Java Media Framework</a>
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Oct 2, 2011

    this may help you
    #-Link-Snipped-#
  • SheldonCooper

    SheldonCooper

    @sheldoncooper-KRWqFp Oct 5, 2011

    Study the code below.You will get pretty good idea.Modify it according to your needs.And similarly write server code for this code to work.

    package javaapplication1;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    public class Client extends Frame implements ActionListener,Runnable
    {
    Socket s;
    BufferedReader br;
    BufferedWriter bw;
    TextField text;
    Button button1,button2;
    List list;
    public static void main(String args[])
    {
    new Client("Client Application:");
    }
    public void run()
    {
    try
    {
    s.setSoTimeout(1);
    }
    catch(Exception e)
    {
    }
    while(true)
    {
    try
    {
    list.addItem(br.readLine());
    }
    catch(Exception h)
    {}

    }
    }

    public Client(String m)
    {
    super(m);
    setSize(200,300);
    setLocation(300,0);
    this.setLayout(new BorderLayout());
    button1=new Button("Send");
    button2=new Button("Exit");
    button1.addActionListener(this);
    button2.addActionListener(this);
    list=new List();
    text=new TextField();
    add(list,"Center");
    add(button1,"West");
    add(button2,"East");
    add(text,"South");
    setVisible(true);
    try
    {
    s=new Socket("192.168.0.141",100);
    br=new BufferedReader(new InputStreamReader(s.getInputStream()));
    bw=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
    Thread th;
    th=new Thread(this);
    th.start();
    }
    catch(Exception e)
    {
    }
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource().equals(button2))
    {
    System.exit(0);
    }
    else
    {
    try
    {
    bw.write(text.getText());
    bw.newLine();
    bw.flush();
    }
    catch(Exception m)
    {}
    }
    }
    }