Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Java API from .NET - best approach

I need to call an API that's all in java from an existing .NET codebase. What's the best approach here? Writing a webservice in java that basically just forwards the calls to the API - or going with something like JNI4NET?

like image 484
Ciddan Avatar asked May 24 '10 07:05

Ciddan


People also ask

Can I call Java code from C#?

We have heard that it is not possible to call Java code from C# and vice-versa, but jni2net makes it possible by mixing both source code into a single executable file.

Can we use Java with .NET framework?

Java fetches most syntax from C and C++. Since it is a platform-independent language, you can run Java on various platforms . Net works on a common language infrastructure, supports arrays, type checking, checks variables and garbage collection.

Can Java and C# work together?

The first way provides evidence that Java can be linked to C# at the native code level, albeit through C++ wrappers. The second is a means for retaining the useful applet feature of Java in the server- side architecture of web services written in C#.


2 Answers

You can use jni4net, which is a JNI bridge between .Net and Java. (Props to Darin Dimitrov for providing this info in an answer to another question.)

like image 118
T.J. Crowder Avatar answered Sep 28 '22 08:09

T.J. Crowder


That depends. If it is a desktop application, you can use JNI. But for a web based application you have to use the web services.

like image 30
Ravindra Gullapalli Avatar answered Sep 28 '22 07:09

Ravindra Gullapalli