Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass values between JVMs

 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to pass values from one JVM to another ? System.setProperty() and System.getProperty() works within the single JVM. Any thoughts ?
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a concept called serialization in Java. Read this
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kri shan wrote:How to pass values from one JVM to another ?


Your basic options are network, file, and shared memory. Java doesn't include a shared memory feature in the core API, so that option is out, unless you want to use JNI or JNA to interface with native code.

Or you could connect the System.out of one JVM directly to the System.in of the other.

 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote: Or you could connect the System.out of one JVM directly to the System.in of the other.

I didn't get this Jeff... Do you mean to say that we'll have to use an intermediate file as buffer?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anayonkar Shivalkar wrote:
Jeff Verdegan wrote: Or you could connect the System.out of one JVM directly to the System.in of the other.

I didn't get this Jeff... Do you mean to say that we'll have to use an intermediate file as buffer?


I meant an "out-of-band" approach. In Linux shells it's accomplished by the pipe operator.



Everything the first java command sends to System.out can be read by the second java command's system.in.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote: I meant an "out-of-band" approach. In Linux shells it's accomplished by the pipe operator.

Got it. Thanks
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> In Linux shells it's accomplished by the pipe operator.

In Windows cmd.exe too.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't we use serialization Jeff? Is that not a correct option in this use case?
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialization is a way to turn Java objects into a data stream or the other way around. It can help package the data to be exchanged.

But the conduit, the channel to exchange them is another question. You write (and read) ser'ed data to (and from) memory, a file, a socket, a pipe.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Jozsef Balazs wrote:Serialization is a way to turn Java objects into a data stream or the other way around. It can help package the data to be exchanged.

But the conduit, the channel to exchange them is another question. You write (and read) ser'ed data to (and from) memory, a file, a socket, a pipe.


@ Krishan : Sorry man, I gave an irrelevant answer. Take it back.

@ Ivan : Can you perhaps provide a link where I can understand these concepts of pipes / sockets / shared memory? I have no idea what they are or how these can be programmed. Basic entry level tutorial to networking concepts maybe would be of much help.

 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should decide first whether files, (named or unnamed) pipes, sockets (or to an give exotic example shared memory) are best suited for your application.
These are general (non-Java) notions. I have not searched tutorials etc. on them recently, but Google (or your favorite search engine) is your friend.
I am sure an introductory level understanding on sockets can be acquired form a decent Java networking tutorial.
Java Custom Networking

 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ivan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic