Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

While I am able to use InstallJava[] (or ReinstallJava[] for that matter) with a TCP/IP link to a JVM running on the same system just fine (as shown on page 110 of the jlink user guide, e.g. for debugging purposes), I am not able, however, to get InstallJava[] working with a TCP/IP link connecting to a JVM running on a remote system.

When I try to have InstallJava[] connect to the remote JVM, the link itself seems to connect fine (because when I kill the Mathematica process, the remote JVM exits as expected), but InstallJava[] never returns and cannot be interrupted/aborted.

(Tried this with links from Linux 64 (Mathematica) to Windows 64 (jvm) and Linux 64 to Linux 64. Used JVMs installed with Mathematica and others. No problems with underlying link communications, remote or local. Just InstallJava[] hangs exclusively with remote JVMs.)

Questions:

  1. Is this not supported?
  2. If it is supported, how to troubleshoot?

Thank you!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

InstallJava[..] creates extra links for internal communication. By default these extra links are created with the SharedMemory protocol even though the main link that is used with InstallJava[ml] may specify the tcpip protocol. This means that the wiring/connecting of the internal links fails as they obviously cannot communicate via shared memory on remote systems.

The solution is to override the protocol these extra links use in InstallJava[] and force them to use the tcpip protocol. Then, remoting with the "installed java" feature works as expected. It would be nice, if Wolfram could adjust the InstallJava code to use the same protocol for the internal extra links as it does for the main link.

share|improve this answer
    
This answer is exactly right about the source of the problem. J/Link could be smarter about the protocol to use for the extra links. Even simpler, it should not bother to use extra links when the TCPIP protocol is in use, since that almost certainly means that the JVM is on a remote machine, and the extra links are mainly for running Java user interface elements, which would not be useful popping up on a remote machine. There is a workaround, which is to use the CreateExtraLinks->False option in InstallJava. That documentation example is very old and needs to be updated to show this option. –  Todd Gayley Nov 8 '13 at 18:55
    
By the way, kudos to luke for looking at the source code and figuring the solution out. Mathematica developers don't expect users to read their source code to figure out problems (and sometimes we cringe at the thought), but there is often quite a lot to be learned by looking at the code, and users have on several occasions identified bugs in my code down to the line number. I just committed a fix to this problem in the way I suggested above--by changing the default behavior so as not to establish extra links in the case of a remote JVM. –  Todd Gayley Nov 8 '13 at 19:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.