• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface a C/C++ native app to a Java app  RSS feed

 
Faraz Syed
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, this may be a very strange and weird question, but... is there any way to interface (or launch) a Java application _FROM_ a native C, C++ application?

It would appear that the only way to do this is using either fork/exec (for UNIX platforms) or using the system() std C library function (portable - in theory!).

Does anyone have any other ideas on this could be achieved?

I would like to be able to run a java app from a Windows DLL or a UNIX shared library.

Thanks.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JNI. It's not just one way from Java to native code (C/C++) - it goes the other way as well. In C/C++, you create a reference to the JVM, then use that to launch your Java code.
 
Faraz Syed
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Rob,

I didn't know that JNI worked in the "other" direction too. I am looking into this right now, but are you aware of any other issues or limitations in using JNI to accomplish this?
Obviously, using JNI for this is vastly preferable to either one of fork/exec/system.

Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!