Using .Net library through COM or direct integration in Java

I have to admit that the last time I programmed in Java was a data structure class in high school. So please be kind to this Java noob.

I spent a lot of time building the C # COM library at work. This library relies heavily on some new .Net technologies (WPF is big), so translating into another language is actually not an option. I tested this library from C ++ through the COM interface, and it was quite simple. I would also like to prove that the same library can be used from a Java program.

So, the problem I am facing is that I cannot find a free or even inexpensive way to use COM objects from Java. I think another solution would be to find a way to directly integrate the library. Does anyone have any input on what might be the best way to do this? I am using Eclipse for my java environment. Below is an example of what my C # code looks like. Thanks for any direction you can provide.

//Example C# Object Code [Serializable, ComVisibleAttribute(true), Guid("Long Guid String"), ClassInterface(ClassInterfaceType.None), ComSourceInterfaces(typeof(IFooBarStructure)), ProgID("My Application")] public class MyFooBarObject { public MyFooBarObject(){} public string DotNetMethod(){ return String.Empty; } } 
+3
source share
5 answers

You can use jacob

From the website:

JACOB is a JAVA-COM bridge that allows you to invoke COM Automation components from Java. It uses JNI to create its own calls in the COM and Win32 libraries.

Sounds like you're looking.

+1
source

If you have some money to spend on a commercial product, I recommend that you take a look at Intrinsyc J-Integra for COM or J-Integra for .NET . I used my COM product to access a third-party ActiveX control (Bloomberg data access library) from Java code for a project that I worked on several years ago, and it worked very well. They have a reasonable trial / demo policy, and they are quite responsive to support requests.

+1
source

If you can access your library through C ++, you can access it through JNI. JNI is pretty easy to do, just read the manual , especially in section 8.6, which talks about the differences between C and C ++

0
source

Direct integration with Java / .NET can be done using OOJNI. Google "Object Oriented JNI for .NET."

0
source

I am the author of jni4net , an open source interprocess bridge between the JVM and the CLR. It is built on top of JNI and PInvoke. No C / C ++ code required. Hope this helps you.

0
source

Source: https://habr.com/ru/post/1379733/


All Articles