File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes can RMI and VB talk? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "can RMI and VB talk?" Watch "can RMI and VB talk?" New topic

can RMI and VB talk?

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
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.
Shay Gaghe
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

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
Sahir Shibley
Ranch Hand

Joined: Apr 08, 2000
Posts: 275
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 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/ 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\"
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.
david rawheiser

Joined: Jun 12, 2001
Posts: 3
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
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).
I agree. Here's the link:
subject: can RMI and VB talk?
It's not a secret anymore!