I'm interning as a software developer for a company. There is a client-installed software program written in C# that has dll's in VB - both on the .NET framework. Our entire cloud-based server is written in Java, so for now, my task is simply to call a function in Java that gets/sets a private(? sorry, not really familiar with VB so I might be using this term inappropriately) variable located within the dll. Ultimately, though, my task will be to collect data from the client program and put it in our server. I've been researching how to go about doing this for the past few days and have found a few options:
Java Native Access (JNA)
Java Native Interface (JNI)
COM/ActiveX bridges (though I can't entirely say for sure that I know what these are/how to use them_
JNBridge
Now as far as I know, these are the issues I've found with each, respectively:
Using this option requires an intermediary from Java to .NET using either C or C++, and given that I only really know Java, I'd not really like to get tangled in this mess.
Seems a tad bit more complicated than JNA, and I think it has no real advantages over JNA anyways. They both appear to have the need of a C/C++ intermediary.
... can't really say much aside from the fact that I'm not really sure how I can go about implementing this method.
This and other similar bridges has to be a last resort. The developer license for this product is quite pricey, and I'm sure they we don't have the resource to use this product. I could try asking, but I don't really think it's in the place of an intern to ask that a company invest so much.
To add to the fact that I'm not really that adept in programming, I've been left to mostly do this on my own so thanks so much in advance for reading my question. If there's something I haven't fully explained that necessitates further explanation, please let me know! Any other tips/pointers would be immensely appreciated.
解决方案
I can recommand JNA together with UnmanagedExports since it requires only C#, VB.NET or F# .dll with the following Header
C#:
[RGiesecke.DllExport.DllExport]
public static String yourFunction(String yourParameter)
{
return "CSharp String";
}
after that you can consume it with JNA like any other C or C++ .dll in Java. You can find an example and some restrictions I couldn't come around in my answer at this similar question: Call DLL from Java using JNA
I only tried it with C#, but as stated in the docu it should work with C#, F# and VB.NET.