# J/Link: InstallJava[..] or ReinstallJava[..] hangs when used with a link to a remote jvm running Install.main

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!

-

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.
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