MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: JLink .. how to enable kernel tracing ?

  • To: mathgroup at
  • Subject: [mg27224] Re: JLink .. how to enable kernel tracing ?
  • From: tgayley at (Todd Gayley)
  • Date: Mon, 12 Feb 2001 03:21:02 -0500 (EST)
  • Sender: owner-wri-mathgroup at

>Dear all !
>I need to call via JLink a Mathemtica
>kernel from Java ..
>It works fine ..
>But it is hard to find out, when
>something goes wrong ..
>i.e. execute works without semicolon ..
>mykernel.execute("3+4"); //.. works 
>mykernel.execute("3+4;"); //.. works not ..
>The Porblem is, in this case you could see
>it the result .. but other cases maybe
>not ..
>Is their a way , to see the kernel output
>in the same like if I would execute 
>it a a normal math-shell ?
>Can I maybe redirect the kernel output somehow ?
>Many thanks for any hint !
>	Frank


J/Link gives you the same output that you see in a normal math shell (or notebook
session). If you evaluate

    3 + 4;

you don't see any output either in a notebook or from the J/Link method
evaluateToOutputForm(). (I don't know what the execute() method is, but I assume it is
either a misprint or your own method that calls evaluateToOutputForm().)

If you want to get something other than null returned from evaluateToOutputForm(), don't
end your input with a semicolon.

If you are talking about seeing side effects like Mathematica warning messages and Print
output, then there is a very easy way to do this. Take a look at the PacketPrinter class
(section 2.8.5 of the J/Link User Guide). Just add the following two lines after you have
opened the link to Mathematica:

PacketListener stdoutPrinter = new PacketPrinter(System.out);

Now you will see everything that comes from Mathematica, not just the final result,
printed in the stdout window. You can get much fancier if you like, such as filtering for
packets of interest or writing output to an AWT window in your Java program, etc.

Todd Gayley
Wolfram Research

  • Prev by Date: Re: J/Link MathCanvas/Graphics/Interaction
  • Next by Date: Re: Genetic Algorithms?
  • Previous by thread: Re: JLink .. how to enable kernel tracing ?
  • Next by thread: RotateShape[Cuboid...