Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java, Graphics Output, MathCanvas

19 views
Skip to first unread message

Torsten Hartwig

unread,
Jun 14, 2001, 2:35:06 AM6/14/01
to
Hi,

im new to mathematica, so i hope you can help me. i've installed mathematica
v4.1 and i created a little java application that works with Jlink. one can
feed a function and the application returns the derivation of this
function. now i tryd to display the answer as a graphic(or a typeset, i dont
know the difference) in a MathCanvas, but it doesn't work. i even tested the
example GraphicsApp thats in the Jlink folder, but that doesnt work, too. it
is possible to display mathematica-expression in a MathCanvas at all ? i use
VisualCafe4.1 in combination with JDK1.2.
the code relevant to the problem is as follows:

instance-variable:

MathCanvas MathCan = new MathCanvas();

constructor:

this.MathCan.setBounds(12,86,372,240);
this.MathCan.setBackground(Color.lightGray);
this.MathCan.setImageType(this.MathCan.TYPESET);
or
this.MathCan.setImageType(this.MathCan.GRAPHICS);
computation-method:

KernelLink link = null;

try
{
link = MathLinkFactory.createKernelLink("-linkmode launch -linkname
'C:/Programme/Wolfram Research/Mathematica/4.1/mathkernel.exe'");
}
catch (MathLinkException e)
{
System.out.println("No KernelLink");
}

try
{

this.MathCan.setMathCommand("D[3x^2,x]");
or
this.MathCan.setMathCommand("Plot[x,{x,0,1}]");

}
catch (MathLinkException e)
{
System.out.println("Error");
}

link.close();

thanks,
torsten

Torsten Hartwig

unread,
Jun 14, 2001, 2:58:37 AM6/14/01
to

Todd Gayley

unread,
Jun 15, 2001, 5:58:49 AM6/15/01
to
Torsten,

Your code looks reasonable, so let's first figure out what the problem
is with the example GraphicsApp program. In what way does it not work
for you? Does the program launch normally but just not display output
when you click the Evaluate button? Does the Mathematica front end
launch along with the kernel when you start GraphicsApp (it should)?
Please give as many details as you can about what happens.


--Todd Gayley
Wolfram Research

Torsten Hartwig

unread,
Jun 16, 2001, 2:54:37 AM6/16/01
to
Hi again,

yes, the GraphicsApp example lauch normally, the MathKernel starts normally,
but when i push the evaluate-button the MathCanvas stays cleared. I tried
something like D[3x^4,x] and marks TYPESET or Plot[x,{0,1,x}] and marks
GRAPHICS. But I gave my GraphicsApp example as a VisualCafe-Projekt to
friend an he tried out the programm...and it works.

I really dont know what you mean with :


"Does the Mathematica front end launch along with the kernel when you start
GraphicsApp (it should)?"

I will search the manual for the front end and study it. I think if the
GraphicsApp example will work, my own Projekt will work,too.

thanks a lot, torsten

"Todd Gayley" <tga...@wolfram.com> schrieb im Newsbeitrag
news:9gcm8p$362$1...@smc.vnet.net...

Todd Gayley

unread,
Jun 16, 2001, 10:45:19 PM6/16/01
to
On Sat, 16 Jun 2001 06:54:37 +0000 (UTC), "Torsten Hartwig" <torsten...@web.de> wrote:

>Hi again,
>
>yes, the GraphicsApp example lauch normally, the MathKernel starts normally,
>but when i push the evaluate-button the MathCanvas stays cleared. I tried
>something like D[3x^4,x] and marks TYPESET or Plot[x,{0,1,x}] and marks
>GRAPHICS. But I gave my GraphicsApp example as a VisualCafe-Projekt to
>friend an he tried out the programm...and it works.
>
>I really dont know what you mean with :
>"Does the Mathematica front end launch along with the kernel when you start
>GraphicsApp (it should)?"
>
>I will search the manual for the front end and study it. I think if the
>GraphicsApp example will work, my own Projekt will work,too.
>
>thanks a lot, torsten
>

Torsten,

What I mean by "does the front end launch" is the following. When Java
launches the Mathematica kernel, you will see it appear in the Windows
taskbar. Programs like GraphicsApp that use the services of the
Mathematica notebook front end need to launch the front end as well as
the kernel. You should see another process called "Mathematica 4.1" (or
something like that) show up in the taskbar. Thus my question is
whether you see just one program (Mathematica kernel) appear in the
taskbar, or two.

My guess is that you don't see the front end launch, and I think I know
why. J/Link must be properly installed for GraphicsApp to work.
Specifically, the JLink.m file needs to be read into the kernel by the
internals of J/Link, so it must be somewhere the kernel can find it.
Make sure you have followed the J/Link installation instructions. There
should be a JLink directory containing the file JLink.m (and several
other subdirectories) in your <Mathematica dir>/AddOns/Applications
directory.


--Todd Gayley
Wolfram Research

Torsten Hartwig

unread,
Jun 18, 2001, 3:49:42 AM6/18/01
to
Hello again,

the problem is solved. i thougt it is enough to save the jlink - directory
somewhere on the harddisc and create a link to its class-library.

But now i exactly followed the jlink installation guide and it works. I have
installed the Jlink-directory in Addons/Applications ! When I start my
program the second process called "mathematica" is shown in the taskbar.

sorry for my naivety :-)

thank you very much, torsten !

"Todd Gayley" <tga...@wolfram.com> schrieb im Newsbeitrag

news:9gh5jv$9cj$1...@smc.vnet.net...

0 new messages