How do I establish a connection to another Java program on the net?

Hi all,
I have been reading the java tutorial to find a solution to my problem but I havent really found what Im looking for.
I want to establish a connection that allows a client to get a copy of an object from a running java-application on a server on the internet.
I have read about the Socket-class but the tutoral advices only to use it on a locale network. I know IDL and RMI only by name - is this what I should be reading about?
If one of you guys have a source-code example on how to make java programs communicate over the net, please post it!
Regards Albert

Assuming this is "wide area" stuff, not just on a local area network, your best bet is to stick to http connections. You need a web server, probably Tomcat.
Your client can connect using URL.openConnection().
As to protocols you could use SOAP. It has the advantage that you can get the code for it for free, but it can be pretty complicated to configure. In particular it only knows how to transmit a limited set of object types and if you want to go beyond them you have to write converters. SOAP servers typically run under an web server anyway. SOAP converts all the data to XML for transmission.
However it may be simpler to use Java's built in serialisation facility and send your data as an ObjectStream.
In the set up you're talking about the message going to the server seems a lot simpler than the response. It may make sense to send your data as normal keyword parameters of a POST transaction but to have the server respond with an Object stream. That's well within the normal operation of a web server.

Similar Messages

  • Is there any way to make a socket connection to a java file on the net?

    Is their anyway to make a socket connection to a java applet that I place on a webhost? I want to connect to a javaapplet from my vb.net program and send commands to it. Like http://www.geocities.com/Sylonious/javafile.jpx:7070
    ?

    Is their anyway to make a socket connection to a java
    applet that I place on a webhost? I want to connect to
    a javaapplet from my vb.net program and send commands
    to it. Like
    http://www.geocities.com/Sylonious/javafile.jpx:7070
    ?You wouldn't have a port in the url, you would need to have the socket open in the applet code. The vb.net program would also need to be on the same server as the applet or you'll have security issues and I doubt that's possible with geocities. I don't know what you would need to communicate with a vb.net if anything, but I'm sure it's possible.

  • How to request Administrator or root to execute java programs?

    How to request Administrator or root to execute java programs when the user is not enough permission?
    as same as following image:
    Windows : http://img151.imageshack.us/img151/6113/winrw5.gif
    Linux: http://img374.imageshack.us/img374/8990/linuxsj4.png
    Edited by: lauangus on 2008?10?13? ??9:15

    Dear Sys Admin,
    Would you please grant me and my group enough rights to do the tasks that have been assigned to us, we are using the following programs. They will need to asccess....
    Sincerely,
    lauangus
    Note: this will usually have to be accompanied by appropriate supervisor signatures and endorsements.

  • How can I establish bluetooth connection with my iPhone so I can share and modify my iPhone's contact list on my macbook?

    How can I establish bluetooth connection with my iPhone so I can share and modify my iPhone's contact list on my macbook?

    The Mac and iPhone sync with iTunes though the charge cable that is included with the iPhone. Through this, you can sync your calendars and contacts.
    Bluetooth is an impractical sync scheme as the time it would take to say transfer your song catalog could be longer than your phone contract. I suppose it is entirely possible to implement with hacks and jailbreaking, but I am fairly sure it is beyond the rules here to discuss such activities.
    You may wan tto ask this same question in the iPhone section of the comminitie here. There may be some workarounds for just contacts.

  • How do I control my mac from another mac not in the same network?

    How do I control my mac from another mac not in the same network? Thanks

    You can do it manually, but it is much simpler if you use a tool such as Back To My Mac, LogMeIn, or something like that. Those programs enable you to connect to your computer through your router without you having to adjust the router settings manually.

  • How to use another java program to stop this running prpgram???

    Dear Sir:
    I have following code and I run it success,
    import java.util.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    public class CertainAndRepeatTime{
      public static void main(String[] args) throws IOException{
        int delay = 1;
        Timer timer = new Timer();
        ActionListener actionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              System.out.println("Hello World Timer");
        System.out.println("What do you want (Certain time or Repeat time)?");
        System.out.print("Please enter \'C\' or \'R\' for that: ");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ans = in.readLine();
        System.out.print("Please enter  ans=" + ans  + " IsTrue=  " + (ans.equals("R") || ans.equals("r")) +"\n");
        if (ans.equals("C") || ans.equals("c")){
          //System.out.println("This line is printed only once start...");
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed only once.");
          },delay,1);
        else if(ans.equals("r") || ans.equals("R")){
            timer.scheduleAtFixedRate(new TimerTask(){
              public void run(){
                System.out.println("This line is printed repeatedly.");
            },delay, 1000);
          while(true){
               //System.out.println("Charles print This line is printed repeatedly.");          
          } //This will make your main thread hang.
        else{
          System.out.println("Invalid Entry.");
          System.exit(0);
        System.exit(0);
    }But I hope to use another java program to stop it when it is running instead of pressing CRTL + C to stop it.
    How to do it??
    Any example??
    Thanks a lot!!

    Sorry, I think i did not express cearly. It is my fault.
    I re-write my requirements again:
    I have
    Class AAA1.java,
    Class AAA2.java,
    Class AAA3.java,
    Class AAA20.java...
    etc
    they all look like the program I posted first time,, once executed, they will run for ever, and they will be stopped until I press CRTL + C;
    Now I hope to use another java class StopProgram.java to stop them 1 by 1 or at once instead of pressing CRTL + C;
    In this case, how to code this StopProgram.java ??
    Thanks

  • How do I insert a section with another time signature than the one im inser

    How do I insert a section with another time signature than the one im inser

    Yeah I've been trying to figure this out as well, for example... my song might be 90 bpm and I want to program another track using midi but have it play at 180 bpm. The only way I've found to work around this is to write my 180 bpm part make a sample of this and then loop this into the 90 bpm song.

  • I am not being able to connect to another Apple device using the Face time what settings do i need to check.The device being used is an iPad mini

    I am not being able to connect to another Apple device using the Face time.The device being used is an iPad mini.
    The internet connectivity is perfect the wifi is even working.

    '''plafstudiesdotc'''
    You are welcome.
    '''''So that other users can find answers that have worked, please take a couple of minutes to return to the forum, sign in and click "Solved" next to my answer. Thanks. '''''

  • How to compile and run a .java file from another java program

    hello,
    can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

  • Can we run EXE file/ Another Java Program from Java Application? How?

    Can we run EXE file and another java program from java application?
    Thanks in advance

    Example running adobe acrobat
    String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
    Runtime rn = Runtime.getRuntime();
    Process process = rn.exec(command);
    process.waitFor();rykk

  • I have an ipad2 and we purchased an HP office jet 6600.  I can not connect to print.  In searching the net, I have been advised to get the firmware update but can not find it.  Can you advise?

    I have an ipad2 and we purchased an HP office jet 6600.  I can not connect to print.  In searching the net, I have been advised to get the firmware update but can not find it.  Can you advise?

    Is the HP on the airprint list?
    iOS AirPrint Printers  http://support.apple.com/kb/HT4356
    How to Print from Your iPad: Summary of Printer and Printing Options
    http://ipadacademy.com/2012/03/how-to-print-from-your-ipad-summary-of-printer-an d-printing-options
    Print from iPad / iPhone without AirPrint
    http://ipadhelp.com/ipad-help/print-from-ipad-iphone-without-airprint/
    How to Enable AirPrint on a Mac and Use Any Printer
    http://ipadhelp.com/ipad-help/how-to-use-airprint-with-any-printer/
     Cheers, Tom

  • Acessing objects created by another java program

    ok ill give a higher level view of the problem.....
    i think this is a fundamental problem
    I have 3 java programms which take information and store it. all the type of information is the same so I created a class DataStructure....just to store information. this class i put in a package DataStruts and i call the class in the java programs by " import DataStruts.* ; "
    In the java prog. i create instances of DataStructure like
    eds = new DataStructure();
    in the first java prog i create an instance "eds", in 2nd "ads" and in third "pds".
    now in third prog i want to print all the information so i try to retrieve the data stored in the objects "eds" and "ads" by the previous 2 java programs.
    however the third prog does not recognise the variables eds and ads. i think this is because their instances have been created by the first 2 java programs.
    how do i make these instances of DataStructure available to the last program.??plese let me know.
    thankyou in advance.

    Can someone help me make the connection between the
    statements
    I thought a class's public methods were available
    to any other class that has access to the first
    class.
    and
    They are, but only to code running in the same
    VM.
    The first means that when you're writing a program, if class Foo has a bar() method that's declared public, then the compiler will allow you to call bar() on an in instance of a Foo. That's all it means.
    The second means that if I start two different VMs (two separate Java program's) the publicness that made it legal to call Foo's bar() doesn't automagically give the first program a way to know about or see or call a Foo's bar() in the second one.

  • Is there any way to check another Java program running status?

    HI. I want to write a Java program on hand-set but my program seems needs lots of resources and if there is another Java program running on the same hand-set simultaneously, my program will slow down. So, I want to check if there is another Java program is running on the hand-set, my program will show a message to user reminding user to close another program first.
    Is there any way to do so?

    On most recent devices, the application is not terminated but paused by using phone functions, and can be reactivated from the aplication management software. The javax.microedition.midlet package documentation is quite specific, if a tad obscure, about the MIDlet lifecycle and the role of the MIDelt methods vis-a-vis the AMS.
    {color:#0000ff}http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/midlet/package-summary.html{color}
    Parenthetically, I've never been able to figure out how resumeApp should be used, nor have I seen this method invoked in any of the samples that come with the WTK, but I haven't gone through all of them.
    I believe the still-in-progress MIDP3 will make it possible to have MIDlets that share the screen with native apps and which can be minimized and restored.
    db

  • How to call j2me emulator instance from a java program?

    hi,
    how to call j2me emulator instance from a java program?
    i tried public void startApp(){
    try{
    platformRequest("tel:+5550000");
    }catch(Exception e){
    e.printStackTrace();
    from a j2me midlet itself,
    but it gave illegal access exception.
    do i need any hardware phone connected to my pc?
    please help.

    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    import java.util.*;
    public class OpenExplorer{
    public static void main(String args[]){
         new OpenExplorer();
    public OpenExplorer(){
         try{
         String command = "explorer C:";
         // or String command = "cmd /c explorer C:";
         Runtime runtime = Runtime.getRuntime();
         Process process = runtime.exec(command);
         int exitVal = process.waitFor();
         System.out.println("Exit Value: " + exitVal);
         } catch(Exception e){
         e.printStackTrace();
    }

  • How to run an exe file in a java program

    Hi,
    Can somebody tell me how to run an exe file in a java program.
    Thank you!

    Yes, java.lang.Runtime.exec().
    Read this carefully before you do:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Don't write a line of code before you're reviewed and understood the article completely. - MOD

Maybe you are looking for

  • Password for a rpd?

    Hi All, Could any one tell me how to set a Password for a rpd? Thanks in advance.

  • Carriage return on the portal displays as # on the smartform

    Hi,   I am creating an invoice through the portal. In the portal I enter three lines of text for billing header text. After each line I hit a ENTER.   When I view the invoice the three lines in the header text are displayed allright however when I tr

  • Help with the Account user

    i just bought a MacBook wiht 10.4.8, for a couple of days, i had the accounts log in on because my brother wanted to use the laptop, now that i've deleted his account, my login shows up when i restart the computer and the default settings gets restor

  • Smart Playlists and syncing them to my ipod

    i have a smart playlist for recently added songs and they show up in the order that i put them on with the newest ones on the top on my itunes on my computer but when they sync to my ipod they just go in in random order. i dont have my itunes set to

  • Time Machine question--please help!

    I bought an external hard drive. Western Digital MY BOOK. I got it set up appropriately & formatted correctly. The thing I can't figure out is how I mirror (copy) what I have on my IMAC to the external hard drive. I basically want to copy everything