Re: Export with jLink
- To: mathgroup at smc.vnet.net
- Subject: [mg51280] Re: [mg51224] Export with jLink
- From: Todd Gayley <tgayley at wolfram.com>
- Date: Tue, 12 Oct 2004 01:57:43 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
At 03:18 AM 10/9/2004, Jerome Beauquis wrote: >Hello, > >I want to use the power of mathematica from java. > >I would like to extract data from a database (oracle), make some >calculations, creates plots and put those plots in a pdf file. > >I created a mathematica package which generates plots and export them in >.wmf files. >This works when the package is executed in mathematica, but when this >package is called from java with jLink, empty wmf files are created. > >Thanks in advance for your help. Jerome, You will need to provide more details to get any specific help, but I have a suggestion that will probably allow you to find the problem easily. When you use J/Link to call Mathematica, you normally see only the result of the computation, not the full sequence of Print and Message output that is generated. It is very likely that your program is failing in a simple way, but you just can't see it because you do not see warning messages coming from Mathematica. An extremely useful and simple debugging technique is to use J/Link's PacketPrinter class to log all the output that Mathematica sends to your program. This is as simple as adding one line: ml.addPacketListener(new PacketPrinter()); This will cause all the packets that Mathematica sends to Java to be printed on System.out. If your program is not a console program, you can display J/Link's built-in console window by adding just a few lines more (do this before you want to start logging): // At the start of your program: import com.wolfram.jlink.ui.*; .... ConsoleWindow cw = ConsoleWindow.getInstance(); cw.setSize(450, 400); cw.show(); cw.setCapture(ConsoleWindow.STDOUT | ConsoleWindow.STDERR); If you do this, it's likely that you will see the problem right away--a package isn't being found, a function is returning unevaluated because you gave it bad arguments, etc. Todd Gayley Wolfram Research