Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3320830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:59:25+00:00 2026-05-17T22:59:25+00:00

I am writing a RMI chat program. In my program I am able to

  • 0

I am writing a RMI chat program. In my program I am able to receive and send messages, but i am not able to display it in the TextArea. I am not sure what is the error. I tried using Event Dispatch method also. It doesn’t help.

public class client extends javax.swing.JFrame implements inter {

public client() {
    initComponents();
}


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        final inter i = (inter) Naming.lookup("rmi://localhost:1111/client1");
        final String msg = jTextField1.getText();
        if (msg.length() > 0) {
            jTextArea1.append("Me :" + msg);
            java.awt.EventQueue.invokeLater(new Runnable() {

                public void run() {
                    try {
                        i.rcvMsg("Client 1 : " + msg);
                    } catch (RemoteException ex) {
                    }
                }
            });


        }
    } catch (RemoteException ex) {
     } catch (NotBoundException ex) {
     } catch (MalformedURLException ex) {
     }
}                                        

 public void rcvMsg(String msg) {
    final String s = msg;
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            System.out.println("server called");
            System.out.println(s);
            jTextArea1.append(s);
            System.out.println("client msg" + java.awt.EventQueue.isDispatchThread());
            jTextArea1.update(jTextArea1.getGraphics());
        }
    });
}

public static void main(String args[]) {
    try {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new client().setVisible(true);
            }
        });
        client c2 = new client();
        inter stub = (inter) UnicastRemoteObject.exportObject(c2, 0);
        Registry registry = LocateRegistry.createRegistry(1113);
        registry.bind("client2", stub);
    } catch (AlreadyBoundException ex) {
    } catch (AccessException ex) {
    } catch (RemoteException ex) {
    }
}
}

Please help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:59:25+00:00Added an answer on May 17, 2026 at 10:59 pm

    just sharing some information using getGraphics() is not appreciated and can cause problems,

    jTextArea1.update(jTextArea1.getGraphics());

    and i have also created chat application with RMI:

    Pass by reference problem in RMI? there is also client written over there, may be that would be useful for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a small utility to send JMS messages to a remote server,
I'm writing an rmi application. Everything works perfectly fine when i put the all
I am writing a very simple RMI server, and I am seeing intermittent java.rmi.NoSuchObjectExceptions
I'm writing a simple distributed java rmi application and I have a bunch of
In a simple RMI game I'm writing (an assignment in uni), I reveice: java.rmi.MarshalException:
I'm writing a client-server solution which is using Java RMI (Via the Cajo project).
Writing some test scripts in IronPython, I want to verify whether a window is
Writing the code for the user authentication portion of a web site (including account
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.