Hello everyone, Considering various disadvantages of JNI (eg. it makes the code platform dependent) what is best alternative to it when calling code written in C/C++ ? Is CORBA a viable solution ? I understand that CORBA is basically for distributed application environment but since it also gives language independence, can it be considered an effective solution for connecting Java and C/C++ code ? If not CORBA then which is the other effective solution ? Please let me know if there r any products available which give 100% platform independence ? Regards Amit
It all depends on your application, and the data/calls you wish to pass between the Java and C++ components. I've had great success using sockets and passing my own data formats between them. Others do this too:- Apache JServ uses raw sockets to communicate between the Apache web server (in C/C++) and the JServ servlet engine (in Java), for example. Can you tell us a little more about the requirements of your application?
Frank, thanks for showing u'r interest. I have a .dll file which is given to me by the client. My job is to give a 100% java solution which uses functions from this .dll. In all probability, my Java code and the .dll file r going to reside on the machine. So the possibility of using sockets is ruled out. I have even tried out the CORBA solution using trial version of Visibroker for Java and C++. But I am skeptical of its performance during heavy traffic. Hence I have been successful with both JNI as well as CORBA. Is there any other better solution which u could suggest ? Any help would be of great help. Regards Amit
Amit Patkar wrote: In all probability, my Java code and the .dll file r going to reside on the machine. So the possibility of using sockets is ruled out. Not at all. Sockets are always available for access from the same machine (just use the special machine name "localhost" or the loopback IP address 127.0.0.1). I have produced many successful systems using sockets to talk to local software, and the example of Apache Jserv I gave is most commonly run with both the web server and the servlet engine on the same machine. On the other hand, if you are accessing functions from a supplied DLL, the system is platform-dependent anyway, so I'd recommend looking at JNI again. JNI is almost always the most efficient method of communicating between Java and C/C++.