Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6555
| From | Nilo de Roock <ndroock1@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | How-to create a mathematica notebook in a Java program ? |
| Date | 2011-11-20 10:35 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jaal5c$133$1@smc.vnet.net> (permalink) |
The Java program below is self-contained and works. It starts a Mathematica kernel, asks the kernel for Sum[k^2,{k,1,11}] and retrieves and prints the answer. I want to do it differently. I want the kernel to create a Notebook, put Sum[k^2,{k,1,11}] in it, evaluate it and show it on screen. - Is that possible from within a Java program? - If yes, then how do I do it??
package graphica;
import com.wolfram.jlink.*;
/**
*
* @author Nilo
*/
public class MathematicaTester {
public static void main(String[] args) {
KernelLink ml = null;
String jLinkDir = "C:\\Program Files\\Wolfram Research\\Mathematica\\8.0\\SystemFiles\\Links\\JLink";
System.setProperty("com.wolfram.jlink.libdir", jLinkDir);
try {
ml = MathLinkFactory.createKernelLink("-linkmode launch -linkname'C:\\Program Files\\Wolfram Research\\Mathematica\\8.0\\MathKernel.exe'");
ml.discardAnswer();
String expr = "Sum[k^2,{k,1,11}]";
ml.evaluate(expr);
ml.waitForAnswer();
String x = ml.getString();
System.out.println("Result = " + x);
} catch (MathLinkException e) {
System.out.println("Fatal error opening link: " +
e.getMessage());
return;
}
}
}
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
How-to create a mathematica notebook in a Java program ? Nilo de Roock <ndroock1@gmail.com> - 2011-11-20 10:35 +0000 Re: How-to create a mathematica notebook in a Java program ? David Bailey <dave@removedbailey.co.uk> - 2011-11-21 09:38 +0000
csiph-web