agoel78
April 28th, 2003, 04:58 AM
Does anybody know how I can invoke Java methods from C#?
|
Click to See Complete Forum and Search --> : Invoking java methods from C# agoel78 April 28th, 2003, 04:58 AM Does anybody know how I can invoke Java methods from C#? pareshgh April 30th, 2003, 06:08 PM you can check Java .NET Bridge, http://www.jnbridge.com/ Paresh pareshgh April 30th, 2003, 06:15 PM you can check out Ja.NET from IBM which is a bridge between JAVA EJBs and .NET componets. you can configure and run the EJBs within the .NET environment. check IBM's website for more details. -Paresh pareshgh April 30th, 2003, 06:16 PM forgot to mention that, "Ja.NET incorporates a pure Java implementation of Microsoft's .NET Remoting protocol, meaning that the integration is much tighter and cleaner than simple SOAP (you can pass object references, make callbacks, etc.)" " You can use Ja.NET to access EJBs and other Java objects from a .NET client, as though they were written in C#. It also works in the other direction, allowing access to .NET components from Java clients." The extensive documentation includes examples of using Ja.NET with IBM WebSphere. An evaluation copy is freely downloadable: http://www.intrinsyc.com/jaNET/ -Paresh pareshgh April 30th, 2003, 06:22 PM You can certainly instantiate java classes from C# or VB.NET by simply late binding to a java class with a registry entry. -Paresh agoel78 April 30th, 2003, 11:35 PM Hi paresh !! can u clear me out that how can i instantiate java class from registry entry ? please can u explain it more and if possible please mail me with an example at agoel@aptsoftware.com thanx a million amit pareshgh May 1st, 2003, 10:16 AM Hi, Actually really speaking I haven't tried any samples nor even gotten much time to check that stuff. *but* if you look in google or some sites. I am sure there must exist some samples. I just found out some articles and gave the links to you. Check out the Java and .NET bridge site. IBM site should be good. have you checked java sites and forms , since many of ones have already tried out some samples. if I will get some samples I will forward it to you, thanks - Paresh pareshgh May 1st, 2003, 10:43 AM I got this help from the Internet and did some phrase changing after an intensive search ;) May be the following guidelines may be usefull for you, 1) When creating a COM object: To create a COM object out of your Java class, in VJ++1.1 you use the ActiveX Wizard for Java (under Tools) to create the IDL and effectively register your Java class as a COM object. In VJ6 you just check a box for your class in the COM Classes folder tab under the Project Properties dialog box, which does the "same" thing. (Note: there is a bug that sometimes appears in VJ1.1 such that the IDL it creates uses the same GUID number 3 times, so you must run the Create GUID (under Tools) 3 times and cut and paste the 3 unique GUID numbers into the IDL file and rerun the ActiveX Wizard using this file). This step creates the (IDispatch) interface class and registers it with the COM (and VM) framework. or you may consider J#. NOTE: If you are running the Sun's Java then you will need to figure out how to make out COM objects and make a GUID - IDispatch for it. so you can queryinterface it. 2) When connecting/calling/instantiating/using a COM object from VJ++, you must first make a wrapper for it: in VJ1.1 use Java Type Library Wizard, in VJ6 (under Project) select Add COM Wrapper. In either of these, you find the COM class you want to use and check it. This creates a Type Library and makes it available for your VJ java class to call it from. Note: you will need to make a wrapper. to make a wrapper there are already tools available, search it out. 3) Now for the interesting part: The Microsoft JVM or just VM as they call it has additional capability, so that it understands all aspects of COM and handles much of the COM work for your Java class, behind the scenes. For instance, the MS VM: - automatically adds IUnknown implementations to Java classes (for QueryInterface(), AddRef(), Release(). - the bytecodes created from code like: MyCOMClass_Dispatch myObject = new MyCOMClass(); will actually cause the MS VM to do everything to connect and instantiate the COM object, MyCOMClass. In other words, the MS VM will do a CoCreateInstance and a QueryInterface automatically! So the MyCOMClass may look like a Java class, but really it is only for consumption by a COM "savvy" VM and all methods of it are called through interfaces, and the VM knows how to connect to and call the server that can instantiate it, by using registry GUID lookups, etc. check or get connected to http://www.richardhaleshaw.com/ for further information. (they have courses , classes etc.) -hope this helps a little bit, -Paresh agoel78 May 2nd, 2003, 12:01 AM Thanks a million Paresh !! u were of a great help. I'll bug u again if i need some more help codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |