Reputation: 95
How do I consume a JAR (obviously developed in Java) inside of .Net Core? In .Net world, we could register it as a COM Component and access the same. I know that .Net Core doesn't yet support COM components. Libraries like IKVM / JNBridge do not yet support .Net Core.
Upvotes: 4
Views: 2019
Reputation: 167
COM is a Microsoft technology coupled with Windows operating system, .NET Core aims to be cross-platform. Anyway Microsoft discourage to use COM to develop new applications. JCOBridge package is able to do what you are asking for. The latest release supports Windows x86/x64 and Linux x64. The templates available on Templates shows you how to consume Java API from .NET Core. Setting up the Class Path from the .NET Core application tells to the JVM where your Jar files are and from .NET Core application you can invokes the API of your Jar files. Other examples are available on Examples
UPDATE: on GitHub there are two repositories which can be used as examples to use JARs from .NET (framework, Core and 6). JNet is a project which maps some Java classes, or interfaces, in .NET; KNet extends JNet to use the Maven artifacts of Apache Kafka and expose all APIs of Apache Kafka to .NET applications.
Upvotes: 1