Home All Groups Group Topic Archive Search About

How to invoke java class from .net framework?

Author
14 Oct 2005 2:40 PM
Wedde
Can I use JNI to implement it?

Author
14 Oct 2005 5:00 PM
j-integra_support
If you want an "out of the box" solution, try "J-Integra Espresso"...
the fastest middleware product on the market today! It talks IIOP
between .NET apps and Java/J2EE apps.

For a free evaluation, visit http://j-integra.intrinsyc.com/

Shane Sauer
J-Integra Interoperability Solutions
http://j-integra.intrinsyc.com/
When Web Services are not enough
Author
15 Oct 2005 2:05 PM
Wedde
I got it. Thank you very much!
<j-integra_supp***@intrinsyc.com>
??????:1129309211.721947.80***@g43g2000cwa.googlegroups.com...
Show quote
> If you want an "out of the box" solution, try "J-Integra Espresso"...
> the fastest middleware product on the market today! It talks IIOP
> between .NET apps and Java/J2EE apps.
>
> For a free evaluation, visit http://j-integra.intrinsyc.com/
>
> Shane Sauer
> J-Integra Interoperability Solutions
> http://j-integra.intrinsyc.com/
> When Web Services are not enough
>
Author
15 Oct 2005 3:00 PM
Bjarke Lindberg
Wedde wrote:

> Can I use JNI to implement it?
>

It depends on how you'll invoke the java class. I've succesfully used
the following method.

Pre:
- The java class is contained in a .jar file.
- The .jar file is compatible with the Microsoft JRE.
- The Microsift JRE is installed on the machine. (this isn't installed
in Win XP per default)
- The .jar file is located somewhere in the trustlib path.

To implement a facade to the java class (not tested/compiled):

using System.Reflection;
using System.Runtime.InteropServices;

public class SomeJavaClassFacade {

   private Type type = typeof(object);
   private object javaObject;

   public SomeJavaClassFacade() {
     javaObject =
Marshall.BindToMoniker("java:full.class.name.in.jar.file");
   }

   public void someJavaMethod(object someParam) {
     type.InvokeMember("javaMethodName", BindingFlags.InvokeMethod,
       null, javaObject, new object[] {someParam});
   }

}

Another easy way to use a java class in .NET is to use the IKVM, and
binary convert the java .class (or jar) file to a .NET managed assembly.
I've succesfully tried accomplished this too.

see: http://www.ikvm.net/


/B.invoking :)
Author
21 Oct 2005 3:36 AM
wcitrin
Hope it's not too late.  You can also use JNBridgePro to do the
interop.  The Java code can run in the same process, in a different
process on the same machine, or on a different machine running on the
network.  See www.jnbridge.com for more information.

Wayne Citrin
JNBridge, LLC
http://www.jnbridge.com

AddThis Social Bookmark Button