This is a mirror of official site:

Using the Java Native Interface in C#

| Sunday, August 28, 2011

The JNI or Java Native Interface is a set of features available in the Java platform. Applications that use the JNI can incorporate java code with code written in other languages such as C++, Delphi and C#.

In my example I will show you how to call a couple of Java methods from a C# client.

You can reuse your existing libraries\classes that were previously written in java from your new application written in C#. This means that you do not have to abandon your legacy code written in Java and reinvent the wheel again in C#.

One of the most important things to be familiar with in JNI is Field Descriptors. As you will notice in the test harness when I call a Java method that takes a string parameter, I pass in "Ljava/lang/String;". This represent a field type in the Java programming language. For example, if you wanted to represent an int field then you would use "I", a float field would be "F", and a boolean field would be "Z" etc.

The table below describes the primitive types in the Java programming language and the corresponding types in JNI. All field descriptors that start with L are dealt with as objects (NB a string is passed as an object) and must be terminated by a ";" character. An array type is always prefixed with the "[" character.

Read more: Codeproject
QR: JNICode.aspx

Posted via email from Jasper-net