Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the following code (Java code using JLink).

String arguments = "-linkmode launch -linkname 'math -mathlink'";
KernelLink link = MathLinkFactory.createKernelLink(arguments);
String mathCommand = "applyState[processLRV,{{Q000847$JV$9198831378,Q000847$JV$9198831378.state},{{Null,Null},Null,\"<math><mn>16</mn><mi>p</mi><mo>+</mo><mn>25</mn><mi>p</mi><mo>=</mo><mn>1792</mn></math>\"}}]";
String output = link.evaluateToOutputForm(mathCommand, 0);
System.out.println(output);

If I run the command in math client I get the following output:

In[3]:= applyState[processLRV,{{Q000847$JV$9198831378,Q000847$JV$9198831378.state},{{Null,Null},Null,"<math><mn>16</mn><mi>p</mi><mo>+</mo><mn>25</mn><mi>p</mi><mo>=</mo><mn>1792</mn></math>"}}]                                         

General::aofil: HoldForm["Q000847$JV$9198831378.response"] already open as HoldForm["Q000847$JV$9198831378.response"].

OpenAppend::noopen: Cannot open HoldForm["Q000847$JV$9198831378.response"].

WriteString::strml: HoldForm[$Failed] is not a string, stream, or list of strings and streams.

General::stream: HoldForm[$Failed] is not a string, InputStream[ ], or OutputStream[ ].

OpenRead::noopen: Cannot open HoldForm["Q000847$JV$9198831378.state"].

General::stream: HoldForm[$Failed] is not a string, InputStream[ ], or OutputStream[ ].

General::stream: HoldForm[$Failed] is not a string, InputStream[ ], or OutputStream[ ].

General::stop: Further output of HoldForm[General::stream] will be suppressed during this calculation.

ToExpression::notstrbox: HoldForm[Read[$Failed]] is not a string or a box. ToExpression can only interpret strings or boxes as Mathematica input.
    {{Q000847$JV$9198831378 . state, "reProcessLRV"}, Null, {{Null, Null}, Null, Null}, FullForm["unrecognized syntax Q000847[(16Users`p) + (25Users`p) == 1792]\n"], Null}

General::aofil: HoldForm["Q000847$JV$9198831378.response"] already open as HoldForm["Q000847$JV$9198831378.response"].

OpenAppend::noopen: Cannot open HoldForm["Q000847$JV$9198831378.response"].

WriteString::strml: HoldForm[$Failed] is not a string, stream, or list of strings and streams.

Out[3]= {{Q000847$JV$9198831378 . state, reProcessLRV}, Null, {{Null, Null}, Null, Null}, "unrecognized syntax Q000847[(16Users`p) + (25Users`p) == 1792]\n", Null}

But from my app I just get Out[3] text:

{{Q000847$JV$9198831378 . state, reProcessLRV}, Null, {{Null, Null}, Null, Null}, "unrecognized syntax Q000847[(16Users`p) + (25Users`p) == 1792]\n", Null}

How can I get the text between In[3] and Out[3] using Java code?

Hope it makes sense! :)

share|improve this question
    
My guess is that the messages go to the stderr stream (or whatever the Java equivalent is) and the output to stdout, which is what you read with your app. –  Sjoerd C. de Vries Apr 9 at 16:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.