MathGroup Archive 2006

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

Search the Archive

Problem creating image file via J/Link

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70108] Problem creating image file via J/Link
  • From: "Neil M" <anilm411 at gmail.com>
  • Date: Wed, 4 Oct 2006 05:58:46 -0400 (EDT)

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"

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? 

Thanks.


  • Prev by Date: Re: Bessel K expansion, large argument?
  • Next by Date: Re: Draw approximated normal distribution based on mean, median, percentiles?
  • Previous by thread: Re: Program to add continued fractions with polynomial partial quotients
  • Next by thread: Re: Problem creating image file via J/Link