MathGroup Archive 2006

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

Search the Archive

Re: Problem creating image file via J/Link

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70160] Re: [mg70108] Problem creating image file via J/Link
  • From: Todd Gayley <tgayley at wolfram.com>
  • Date: Fri, 6 Oct 2006 01:58:05 -0400 (EDT)

At 04:58 AM 10/4/2006, Neil M wrote:
>Hi.
>
>For some reason, the very simple J/Link code segment:
>
>       <get kernel link stuff here>
>        ....
>        byte[] gifData = ml.evaluateToImage("Plot[Sin[x],{x,0,2
>Pi}]",0,0,0, false);
>         try {
>             FileOutputStream s = new FileOutputStream(new
>File("foo.gif"));
>             s.write(gifData);
>             s.close();
>         } catch (IOException e) {System.out.println("Failed to open
>file.");}
>
>creates a graphics file "foo.gif" with nothing in it except the text
>"In[1]:="
>
>I attached a packet listener to see what was happening and it produced
>this little nugget:
>
>Packet type was ReturnPacket. Contents follows.
>"In[1]:= "
>Packet type was ReturnPacket. Contents follows.
>"Null"


Neil,

What version of Mathematica are you using? I think you will need to post a 
complete program that behaves this way. Something very strange must be 
going on in the omitted portion at the beginning.


>I tried another route. Created a little stub routine Test.m which had
>the function:
>disFig[] := [<stuff>
>                   Display["foo.gif", Plot[Sin[x], {x, 0, 2 Pi}], "GIF"]
>]
>Then I called Test.m in a J/Link program via the lines:
>           ml.evaluate("<<Test.m");
>           ml.discardAnswer();
>           ml.evaluate("disFig[]");
>
>Same result: A file foo.gif with only the line "In[1]:=".
>
>Any ideas on what's going wrong?


That foo.gif must be the one produced by your first example. There's just 
no way that this second example could produce an image like that. It's 
either not producing a file at all, or it's putting it in a place you are 
not expecting.


Todd Gayley



  • Prev by Date: Re: Google Mathematica code search
  • Next by Date: RE: FrameTicks
  • Previous by thread: Problem creating image file via J/Link
  • Next by thread: RE:Dual Core