Hi im developing a chat program RMI based. Since the GUI in java handled by layouts and doesn’t fit to my needs (as a graphic designer) I found that Visual Basic is more suitable and faster tool to take care of the GUI development. There is a way to connect a Java server (RMI) and a Visual Basic client? If so I would like to receive source to learn how to establish this communication. Thanks Shay Gaghe
Well, yes and no. VB does not natively connect with a remote VM (you can guess why), and has no built-in communication interface for talking 'natively' to that protocol. One way to do this, however, as long as the client has a JVM locally available: you could encapsulate the RMI behavior as a JavaBean, which could then be bridged into an OLE/COM container, which could then be added to a VB application. Or you can go fishing on the internet for such a solution, and see if someone's already done that, but my guess is such solutions have probably been custom written. You don't find too many people who want VB front ends but Java communication. I don't know much about it, but wouldn't SOAP be the easier thing to integrate?
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
You can call the methods of a Java class on a remote server by packaging the java class as an ActiveX control. The steps are as follows. [assuming c:/java is defined as your class path and the package name you have used is com.shay.beans; , and your class name is TestBean.class]
1. Copy the class file to the folder c:\java\com\shay\beans 2. Using any text editor create a manifest file called manifest.mf and copy it to c:\jaba\meta-inf\manifest. The manifest file should contain the text Name : com/shay/beans/Enigma.class Java-Bean : True There should be no spaces before of after the text. Watch out for trailing spaces after the last character. 3. Run the jar utility with the following parameters. jar -cvfm MyBean.jar meta-inf/manifest.mf com/shay/bean/TestBean.class
You get a jar file called MyBean.jar . Open it with winzip to verify the contents of the manifest file. If it does not read as it should you can delete the manifest file and insert one using winzip, but remember that the path should read as "\meta-inf\manifest.mf" 4. Start the packager utility with the command java -classpath d:/jdk1.3/jre/lib/jaws.jar sun.beans.ole.Packager This has a GUI and is rather easy to use. Just select MyBean.jar and it does the rest. 5. The packager generates a .reg file and .tlb (type library) file. 6. Double click the registry file to register the component. 7. Once you have the ActiveX control registered on the server you can access it from the client by using the CreateObject method. Dim myVariant as Variant Set myVariant = CreateObject("ObjectName", "ServerName")
You need not have a VM on the client. All this stuff has to be done on the server. Your client machine will just have the VB front end.
If you did want to run the JVM locally with the VB front-end ... There is a beta COM Bridge that I have played around with and it appears to work. JavaTM 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0 Early Access http://developer.java.sun.com/developer/earlyAccess/j2eecas/download-com-bridge.html I don't know when that would be getting out of beta, but you would be able to run some of the business logic locally (helpful for performance reasons).