Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java RMI with Scala, is this possible?

Java RMI -Remote Method Invocation- is Java to Java only.

On the Scala website I read that the integration with Java is seamless and that:

Scala programs run on the Java VM, are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. You can call Scala from Java and you can call Java from Scala, the integration is seamless.

Does this mean that I can successfully use a Java to Scala RMI?

Did anyone experiment this first-hand?

EDIT:

Any known or discovered gotchas??

like image 603
Marsellus Wallace Avatar asked Jul 20 '11 14:07

Marsellus Wallace


People also ask

Can scala use Java libraries?

Scala is designed to work smoothly with Java and Java libraries like JMSL. This is clearly evident in how Scala picks up the same CLASSPATH environment variable Java uses, so if the Java library you wish to use is already there in the CLASSPATH, then you're good to go.


2 Answers

Yes, here's a link to a message thread where it looks like somebody's done it. It says:

Yes it can! Thanks for help. I now have a little RMI-based pair of Scala programs that will be performing transfers of documents from one Documentum system to another (of a previous version); the Scala code is interacting very nicely with the Documentum Java libraries.

Figuring out how to get the method signatures to include throws RemoteException seems to have been the biggest hurdle.

like image 162
Nathan Hughes Avatar answered Oct 11 '22 20:10

Nathan Hughes


Yes, this can be done. The rmi compiler works with java byte code, so the language used really doesn't matter. I've done this for a class project.

like image 35
Kim Stebel Avatar answered Oct 11 '22 20:10

Kim Stebel