Interacting with java code from C#

.net, c#, cross-language, java

Solution

Sorry, you `cannot` call java `code / classes` `Directly` from C# code.

One way of doing this is to `wrap` up your java classes in a `java Web Service` and call classes `indirectly` through that web service interface in your C# code.

Another way is using `javareg.exe` which exposes java classes as `COM`. You can find it at following location:

C:\Program Files\Microsoft VisualStudio\VIntDev98\bin\javareg.exe

Following posts might help as well

- Calling Java Classes Directly from .NET (uses runtime bridge)

- Calling Java from Microsoft.NET

Problem

We've written a Java program which we are looking to use and interact with from C#. What are our options? Optimally it would be possible to compile the Java application as a library (.DLL) that we could reference from C# perhaps using P/Invoke. This, however, doesn't appear to be an option according to the first few searches online. We opt to be able to use ASP.NET to built a search engine powered by the Java code, so if this opens up for any other options please let us know.

Original source

Related problems