Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Communication between two Separate Java Program in the same Computer (Please Help Me)

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Communication between two Separate Java Program in the same Computer (Please Help Me)

    Hello

    Please help me :

    I explain my problem under a example .

    I have two separate java Program that run on the same
    computer : Program -1 & Program-2 .


    Explain Program-1 :

    Name of Program -1 is “InputFrame” that is a simple frame that contain a
    JTextField and a Button and a JTextArea .


    Explain Program 2 :

    Name of Program-2 is “OutputFrame” that is a simple frame that contain
    a simple JTextArea that this JTextArea is a Instance object
    from a class with name of “DisplayFrame” .


    This instance object from class of “DisplayFrame” added to
    frame of “OutputFrame” .


    Explain My Problem :

    Now I want run both Program 1 & 2 simultaneously in the same computer
    and when I enter a text in JTextField in Program-1 and after click on
    the Button “OK” that Text Entered in this JTextField In addition to
    JTextArea in Program-1 display In JTextArea in Program-2 .


    Note :

    I do not want use a share file between two Program-1 and -2 Or DataBase .

    Note :

    I want if Program-1 run but Program-2 is not running and i enter a text in JTextFeild in Program-1 , after running Program-2 that Entered Text Displaye in JTextArea in Frame of Program-2 .(Offline Message) .

    Both Source code of Program-1 and Program-2 is Attached .

    Thanks.
    Attached Files Attached Files
    Last edited by navidnmc; September 20th, 2012 at 03:58 AM.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help

    There are several ways to go about doing this, but one that has worked is to use a ServerSocket on one and to connect to the ServerSocket via Sockets on the other. There are several good tutorials that will show you how to do this which can be found with Google.

    Other higher level options include using Java remote method invocation or RMI, Jini also called Apache River, Java Message Service or JMS, or even connect with TCP/IP and communicate using HTTP protocol using web services. The possibilities choices here, fortunately or unfortunately, are enormous. For my money, if all I needed is basic rudimentary communication, then I'd go with a simple Socket set up, but if I needed to implement more complex communication then I'd consider using a higher level construct.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help

    hi "curmudgeon" .

    Thanks for answer .

    I think I got the wrong speech with this example in my post .

    so i'll explain my problem with a new example .

    i have a project with three package that in each package is a seperate class with following name :

    root Package:
    PKG1 -----> InputFrame (CLass)
    PKG2 -----> OutputFrame (Class)
    PKG3 -----> DisplayFrame (Class)


    “InputFrame” class is a simple frame that contain a TextField and a Button and a JTextArea .

    “OutputFrame” is a simple frame that contain a simple JTextArea that this JTextArea is a Instance object
    from a class with name of “DisplayFrame” .


    This instance object from class of “DisplayFrame” added to frame of “OutputFrame” .



    Explain My Problem :

    both class “InputFrame” & “OutputFrame” have separate main method Now I want first run main method in class “InputFrame” and enter a text in JTextField in “InputFrame” and then click on the Button “OK” then after this stage run main method in “OutputFrame” now must that Text Entered in JTextField of “InputFrame” in addition to JTextArea in “InputFrame”
    display In JTextArea in “OutputFrame” .



    Note :

    I do not want use Observe Pattern because all objects that must register and notify in Observer pattern thay are in seperate main method and in seperate package and is not in same method main .



    Note :

    I do not want use a share file between two "InputFrame" and "OutputFrame" Or DataBase .



    Note :

    I want if “InputFrame” run but “OutputFrame” is not running and i enter a text in JTextFeild in “InputFrame” , after running “OutputFrame” that Entered Text Displaye in JTextArea in Frame of “OutputFrame” .(Offline Message) .

    Source code of InputFrame and OutputFrame is Attached .

    Thanks.
    Attached Files Attached Files

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,979
    Thanks
    52
    Thanked 2,270 Times in 2,242 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help

    Please post your code in the forum so it can be seen without a download.
    Be sure to wrap the code in code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help

    hi "curmudgeon" .

    I resolved the problem of my project, and I thank you that helped me .
    I use Socket Connection between two Program and exchange my commands from this connection .

    thanks

  6. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help Me)

    please attach this code

    --- Update ---

    please send the code

  7. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,737
    My Mood
    Mellow
    Thanks
    233
    Thanked 709 Times in 695 Posts

    Default Re: Communication between two Separate Java Program in the same Computer (Please Help Me)

    Please check the dates of threads before responding. A thread with a last post older than ~1 month is "dead" and unlikely to return to life.

    If you're working a similar problem and need help, please post your own thread with the details, including any code you've written.

    Thread closed.

Similar Threads

  1. asynchronous communication instant messenger program......
    By mythicalone in forum Java Networking
    Replies: 3
    Last Post: November 14th, 2011, 09:33 PM
  2. Replies: 1
    Last Post: October 16th, 2011, 10:35 AM
  3. Executing a program on my computer with an ActionListener?
    By FoxBoiii in forum Java Theory & Questions
    Replies: 1
    Last Post: April 29th, 2011, 05:22 PM
  4. updating SWT Slider from separate java class
    By ppmckee in forum AWT / Java Swing
    Replies: 0
    Last Post: April 14th, 2011, 03:23 PM
  5. Replies: 3
    Last Post: March 1st, 2011, 01:18 PM

Tags for this Thread