Re: JLink to remote kernel not possible?
- To: mathgroup at smc.vnet.net
- Subject: [mg52620] Re: [mg52571] JLink to remote kernel not possible?
- From: Todd Gayley <tgayley at wolfram.com>
- Date: Sat, 4 Dec 2004 04:07:59 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
At 01:21 AM 12/2/2004, Zeno Crivelli wrote: >I have a little java app that does some operations connecting to the >kernel via JLink. > >I use the following lines to get a link to the kernel (locally, on my >PowerBook): >-------- >String argsOSX = "-linkmode launch -linkname >'\"/Applications/Mathematica 5.0.app/Contents/MacOS/MathKernel\" >-mathlink'"; >KernelLink ml = MathLinkFactory.createKernelLink(argsOSX); >-------- > >Now, here is what I would like to do (probably a newbie question): > >I have access (via ssh) to a remote kernel ('math' command) on my Unix >machine (let's call it host1.mydomain.edu) which is running >Mathematica 5.0 for Sun Solaris. >I would like my java app to use the remote kernel (on the unix host) >instead of the one installed on my PowerBook (so that I can use the >java app from other computers where there's not Mathematica >installed). Is there a way to do that? I was dreaming it was something >trivial like make the remote kernel listen to a specific port (let's >say 60000) and then, on the java client, use something like >"createKernelLink(...name:pass at host1.mydomain.edu:60000)"...but of >course createKernelLink doesn't seem to accept a remote host as >parameter. > >Please, can anybody help? Zeno, The argument to createKernelLink() is a string or array of the same arguments that all MathLink programs use, so you can find discussion of how to setup a remote Mathematica kernel in various places, including threads in this group. The J/Link User Guide, in fact, has an example of how to do exactly what you want. Find the J/Link docs in the AddOns & Links tab of the Help Browser and look at the section Part 2: Writing Java Programs That Use Mathematica/Creating Links with MathLinkFactory. The example uses rsh instead of ssh and it is based on a Windows client, but it will be easy to modify for your needs. The example is a bit outdated though, in that it uses the TCP protocol. Make sure you use the newer TCPIP protocol, so where you see "-linkprotocol tcp" replace it with "-linkprotocol tcpip". Todd Gayley Wolfram Research