• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to interact with a C/C++ running process from Java?  RSS feed

 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is JNI can be used to call method inside the c/c++ process to get/set data etc?

Or Do I have a to use socket to get into the c/c+ process?

Or any creative or simple suggestions?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNI is used to execute a C/C++ function in your own process. The C/C++ libraries are linked into your process. All the action is within your original process.

Yup, a socket between the two processes or an RPC call (from JNI C/C++ code to the other process) are possibilities.

You could use IBM WebSphere MQ or JMS too of course.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you're looking for is some form of interprocess communication. Just from what you've said, I'd guess using an IPC mechanism makes more sense.

Sockets are the simple, assuming your C++ program binds to a port to begin with and exposes the service method(s) you need.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Huge Thanks! Barry and Michael!

I will check out the directions you guys pointed out, need some digest, of course.

I think I will come back with more questions...

Please bear with me...

Thanks!
[ April 12, 2006: Message edited by: Roseanne Zhang ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!