Message Boards Message Boards

Displaying Graphics through Java

Hi everyone, 
  Am very new to Mathematica so this might be a very basic question. I was interested in making an interface through Java that would display graphics or plots of equations solved through mathematica. I tried using evaluateToImage() but it returns null instead of byte[]. I found later that Mathematica Kernel 8 does not display graphics even when <<JavaGraphics` is used. Can anyone suggest how I can use Graphs generated through Mathematica in Java?
  I have attached a code snippet of what I was trying to do. The print command was used to check what was the error in the code.
Attachments:
POSTED BY: ritu1909
5 Replies
Mr Reiss,
   Definitely sub-optimal behavior.  A correction is in the works for a future release.
POSTED BY: Bruce Miller
Trying this with Version 9 in a Terminal on a mac it turns out that two identical graphics windows open up.  Would this be a bug?
POSTED BY: David Reiss
In 8.0.4 on Mac and Windows and 8.0.1 on Mac just now, this input gave a window with the plot.
In[1]:= <<JavaGraphics`   
-- Java graphics initialized --

In[2]:= Plot[Sin[x]/x,{x,-20,20},PlotRange->All]

Out[2]= -Graphics-

A method that used to be common was to export the plot to a file and launch an
external viewer to look at it.

Have you tried ordinary J/Link to call the Java functions from Mathematica?
  http://reference.wolfram.com/mathematica/JLink/tutorial/Overview.html
POSTED BY: Bruce Miller
@Bruce Miller     The code you uploaded still shows error in my case. I am using a Windows 7 Mathematica 8.0. My work demands more of Java than Mathematica. So I guess calling Mathematica from Java would be a better option. The two things that happen when the code is simultaneously tried in Notebook and kernel is shown. I guess I need to try connecting Notebook in someway if possible.
Attachments:
POSTED BY: ritu1909
The only problem reports I found with this warning message were for the free CDF Player.

Is CDF Player also installed on this computer? It is conceivable (not likely) that the passwords are
getting confused somehow.


To get a better idea what the Mathematica sees, please run these inputs and post them and their outputs.
The "outputs" below are just examples.
 In[1]:= $ReleaseNumber
 Out[1]= 1
 
 In[2]:= $Version
 Out[2]= 8.0 for Microsoft Windows (32-bit) (February 23, 2011)
 
 In[3]:= $PasswordFile
 
 Out[3]= (full path)

In[4]:= FilePrint[$PasswordFile]
       (contents of the licensing file)
POSTED BY: Bruce Miller
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract