Pass String as params from one Java App to another

accepted answer by jverd on OTN

Yes, there are other ways. Is this way not meeting your needs?

  1. There’s another exec() signature that takes an array, where the first element is the command and the rest of the elements are its args. It may or may not be a varargs call. That would look something like this, although it might not work exactly as I have it.

    exec(“cmd”, “/c”, “start”, “java”, “-jar”, “C:\Dialog.jar”, “Passed info”);

// OR

exec(new String[] {"cmd", "/c", "start", "java", "-jar", "C:\\Dialog.jar", "Passed info"});
  1. You could put the information in a file that the second process reads.

  2. You could store the information in a database that the second process queries.

  3. You could have one process open a ServerSocket and the other connect to it and send the data that way.

  4. You could use a higher-level messaging tool like JMS, Active MQ, etc.

  5. You could use RMI.

  6. You could use CORBA.

I’m sure there are other approaches as well.

I have no idea which approach is best suited to your needs. That’s something you’ll need to figure out, although if you can’t decide, if you post more details about your requirements here, somebody may offer some advice.

Leave a Comment