I have a dll namely product.dll created using .NET. How can I access that dll's constructor or method using Java code.
Is it possible to access without using JNI?
You may take a look at jni4net which allows interoperability between the two. IKVM.NET is another alternative. Yet another option is to expose the functionality you have in the .NET library as a SOAP web service which is interoperable and could be consumed from a JAVA client.
There is a commercial product called JNBridgePro that will allow you to easily do this. You can even run the .NET dll inside the Java process if you like. (You can also run the Java and .NET in separate processes and communicate through sockets.) For more information, please see www.jnbridge.com, or contact us at the e-mail address on the Web site. (Yes, I am with JNBridge, but I felt that mentioning the product was appropriate in these circumstances.)
Related
I have been asked by someone to implement communication between a Java application and a Pascal application. I have very little knowledge of Pascal. Is it possible? If so, can someone provide some guidance? Currently I am clueless at this point.
Sure this is possible.
In case if you simply need to use a set of functions implemented on Pascal you can use JNI with the same way as C. I.e. create a DLL for Windows or shared library for UNIX using Pascal with the JNI specific function names.
You can use pas2jni instead of javac -h (or javah) or make your live even simple using JNA
If you are interesting with multi-process integration, i.e. you have one app written on Java and another app written on Pascal you can use SOAP or REST API.
To implementing SOAP on Pascal you can use
Web Service Toolkit
To implement REST on Pascal you can use
mORMot toolkit.
You can use
File system (cross file communications). i.e. you have one shared file which can be read/written by both apps
Network (SOAP/REST)
I have a dll created out of a C#.NET project and I would like to call the methods from a java program. I was wondering as to what sort of opportunities exist to accomplish this and then I came across JNA and JNI. Which one should I use for my purpose? Any suggestions? All I need is to call the methods in a class written using C#.NET and process the results from my Java program.
It would depend on your application, But you could place the C# DLL within a service e.g. WCF and expose the functionality to the Java code that way. Using wsimport to generate your client code within Java.
It saves the need to use cross over tools like JNI...
I'm trying to write a plugin for a Java Application. The plugin should be able to tell the Java Application that new events have been recognized (Observer Design Pattern, Polling ... thats not the point). The problem is that the events are tracked gestures coming from a Microsoft Kinect controller (I´m using C++ and the Microsoft Kinect SDK because I have to). So that means I have to communicate between the Java Application and my Kinect Application.
I thought of something like an adapter design pattern where the Java application is "including" the interface (c++ header file, dll etc.). First I thought of JNI but then I have to write a DLL that will be used on both application sides, right? Another thing I thought of was to provide the gesture data via a protocol like UDP (or something more lightweight?). The last thing I heard of was to write a COM+ assembly ... but to be honest my knowledge about COM+ is rather little.
JAVA APPLICATION << ----- ??? ----- >> KINECT APPLICATION
May be you should have a look at google's Protocol Buffers.
Since you are considering JNI.
I'd suggest you refer to this IBM tutorial.
JNI allows the java application to call c/c++ methods and vice-versa.
Also have a look at this
question, if you are calling java from c++.
I have found some examples such as here, here and here which recommend you either used a shared memory structure or else use sockets.
I think that in this case, letting your programs communicate through sockets would be the best idea since your applications will not be that tightly coupled, so you just need to expose an IP, a port and a set of commands.
According to this it seems possible to create a C++ server on the Kinect, but other than that I can't say much since I have never worked on Kinect related projects.
JNI (Java Native Interface) allows the java application to call c/c++
methods.
All this requires that we have a means of communicating (Integrating Java
with C++) between Java and C++. This is provided by the JNI (Java Native
Interface).
For a practical example of using the JNI and calling native methods from Java, see this InfoWorld article.
I am developing a Java application in which I need to call some C++ functions (from Google Talk library libjingle) . The objective is to run it all on Google App Engine (which only supports Python or Java).
How can I do this?
You need to define native methods in your java code for whatever you want to be implemented in C++ and directly access your native code. Then you run javah on your code and it will generate the C header files for you and you'll need to provide C++ implementations.
The native methods you can call from your Java code like any other methods and still they'll have their implementation written in C++ and talking to whatever other native library directly.
You then need to set the java.library.path system property to include the shared C/C++ libraries that you require: the google library and your own JNI implementation library would be required in this case.
If the library has C bindings through a DLL/SO, I usually prefer writing wrappers in Java using Java Native Access (JNA) rather than writing the bindings in C/C++ using the Java Native Interface (JNI). The former is easier to manipulate as the JNI access to Java objects is a real pain in the neck. However, it's not as obvious to wrap C++ classes using that API.
You might also want to look into the Simplified Wrapper and Interface Generator (SWIG) for automating part of this process!
You can't run native code on App Engine - only JRE code. If there's no avoiding the native code, you'll need to run this part of your app on another system, and call it from your App Engine app - or use the built-in XMPP API, in this case.
I'm supporting a large system written in C++ and we now have a requirement for our application to talk with a third party system which only provides a JTAPI interface. It would appear that I am stuck writing a JTAPI proxy in Java that talks JTAPI on one side and some more language-neutral API on the other. However, this feels like it should be a solved problem and I don't want to unnecessarily re-invent the wheel. What is the best solution to interface to JTAPI from C++? Does such a proxy already exist, or perhaps is there a solution that does not require a Java layer?
This article shows a way to call Java objects from C++.
You can also think of embedding the JVM in your C++ program. This page talks about a possible way to do this. Also see: Embed Java code into your native apps
If your C++ system provides an API, then the easier approach is to write a Java program that wraps the C++ API (using JNI) and call the JTAPI library from there.