Octave from Java

View: New views
16 Messages — Rating Filter:   Alert me  

Octave from Java

by xolotl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is considered the best solution for calling Octave from Java
(_not_ the other way round) nowadays? I am aware of joPAS.

Thanks,

-- O.L.

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Muthiah Annamalai-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just use pipes must work isnt it?
Look at the recent popen2 thread
that allows calling Octave from Python.

Michael Giffoul contributed some insight into this process,
and you just have to convert his m-file code
into Java.

-Muthu


On Dec 26, 2007 9:12 PM, Olivier Lefevre <lefevrol@...> wrote:

> What is considered the best solution for calling Octave from Java
> (_not_ the other way round) nowadays? I am aware of joPAS.
>
> Thanks,
>
> -- O.L.
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 12/27/07, Muthiah Annamalai <muthuspost@...> wrote:
> Just use pipes must work isnt it?
> Look at the recent popen2 thread
> that allows calling Octave from Python.
>
> Michael Giffoul contributed some insight into this process,
> and you just have to convert his m-file code
> into Java.

The java package that is available from octave-forge provides some
Octave access from Java, provided that the initial proces is octave
(octave engine must be initialized): that is something like

octave calls java, which calls octave

Michael.
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by xolotl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Goffioul wrote:
> The java package that is available from octave-forge provides some
> Octave access from Java

Thanks. It's good to know there is something semi-official for that.

-- O.L.

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by ucecesf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 27 2007, Olivier Lefevre wrote:

> What is considered the best solution for calling Octave from Java
> (_not_ the other way round) nowadays? I am aware of joPAS.
>

I'm not sure what the best solution is but I can say that I use the socket
approach quite successfully in practice.

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 27, 2007 4:12 AM, Olivier Lefevre <lefevrol@...> wrote:
> What is considered the best solution for calling Octave from Java
> (_not_ the other way round) nowadays? I am aware of joPAS.

We have written our own Java to Octave code, I have now had time to release it:
  http://launchpad.net/javaoctave

Documentation only exists as JavaDoc comments, if you need more help
just use the "Ask a question" feature on launchpad.

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437  --  Mobil: 3091 2437

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by xolotl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kim Hansen wrote:
> We have written our own Java to Octave code, I have now had time to release it:
>   http://launchpad.net/javaoctave

Thanks! What is the architecture, though: is it a JNI-, socket-
or System.exec()-based kind of interface?

-- O.L.

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 14, 2008 at 9:00 PM, Olivier Lefevre <lefevrol@...> wrote:
> Kim Hansen wrote:
>  > We have written our own Java to Octave code, I have now had time to release it:
>  >   http://launchpad.net/javaoctave
>
>  Thanks! What is the architecture, though: is it a JNI-, socket-
>  or System.exec()-based kind of interface?

System.exec() and it transfers values by using "save -text -" and "load -text -"

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by xolotl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There was already a System.exec()-based Java bridge: joPAS.
Did you find problems with it? Not attacking your solution,
just a question.

Regards,

-- O.L.


_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Feb 15, 2008 at 4:51 AM, Olivier Lefevre <lefevrol@...> wrote:
> There was already a System.exec()-based Java bridge: joPAS.
>  Did you find problems with it? Not attacking your solution,
>  just a question.

I looked at joPAS, but they used a global queue for communicating with
octave, that meant that it was impossible to run two different octave
processes from the same Java program, that was a feature I needed.

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Eric S Fraga :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At Fri, 15 Feb 2008 00:27:17 +0100, Kim Hansen wrote:
>
> System.exec() and it transfers values by using "save -text -" and "load -text -"
>

Have you done any comparisons with socket based (listen) approaches? I
am particularly interested in the impact of Octave start-up time and
file i/o for save and loads. I have a application specific interface
based on listen which works well but does suffer from latency (I tend
to make thousands of calls to Octave in a typical run).

cheers,
eric
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Feb 15, 2008 8:00 PM, Eric S Fraga <e.fraga@...> wrote:

> At Fri, 15 Feb 2008 00:27:17 +0100, Kim Hansen wrote:
> >
> > System.exec() and it transfers values by using "save -text -" and "load -text -"
> >
>
> Have you done any comparisons with socket based (listen) approaches? I
> am particularly interested in the impact of Octave start-up time and
> file i/o for save and loads. I have a application specific interface
> based on listen which works well but does suffer from latency (I tend
> to make thousands of calls to Octave in a typical run).

I have not researched any other way to communicate with octave, as we
haven't had any need for it.

Our application uses some seconds for feeding data into octave, then
calls some octave scripts that works on the data for 10 minutes to an
hour, and then we read the result back within seconds.

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437  --  Mobil: 3091 2437

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Andrea Grassi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kim Hansen-5 wrote:
I have not researched any other way to communicate with octave, as we
haven't had any need for it.

Our application uses some seconds for feeding data into octave, then
calls some octave scripts that works on the data for 10 minutes to an
hour, and then we read the result back within seconds.
Hello Kim,
I'm a student who's making a java program that interface itselfs with octave as part of a thesis. I successful made my own java code to call octave and execute commands. But I am facing a problem and I'd like to know if you have successfully solved this problem (if not I'll make a general question in a separate post :) ) : If I pass a wrong command to octave, it crash (apparently).
Let me use your lib as an example (it seems it is affected, but I don't know if we can avoid it)
if I write :
        Octave o = new Octave();
        o.execute("A=5");
        o.execute("disp(z)");
        o.execute("A=7");

After the execution of "disp(z)" it will crash, making a "Broken pipe" exception right in the next command.
Do you also have this problem? If you faced it, how did you solve it?

Thank you.
Andrea Grassi

Re: Octave from Java

by Kim Hansen-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Feb 28, 2008 at 10:37 PM, Andrea Grassi <andrea.sdl@...> wrote:

>
>  Hello Kim,
>  I'm a student who's making a java program that interface itselfs with octave
>  as part of a thesis. I successful made my own java code to call octave and
>  execute commands. But I am facing a problem and I'd like to know if you have
>  successfully solved this problem (if not I'll make a general question in a
>  separate post :) ) : If I pass a wrong command to octave, it crash
>  (apparently).
>  Let me use your lib as an example (it seems it is affected, but I don't know
>  if we can avoid it)
>  if I write :
>         Octave o = new Octave();
>         o.execute("A=5");
>         o.execute("disp(z)");
>         o.execute("A=7");
>  After the execution of "disp(z)" it will crash, making a "Broken pipe"
>  exception right in the next command.
>  Do you also have this problem? If you faced it, how did you solve it?

I have not done anything to avoid that problem, our solution gets the
exact same "Broken pipe" error.

--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437  --  Mobil: 3091 2437

_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Octave from Java

by Andrea Grassi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kim Hansen-5 wrote:
I have not done anything to avoid that problem, our solution gets the
exact same "Broken pipe" error.
Ok. Thank you anyway for your fast answer. I'll probably post a question in a separate post to see if anyone has solved this. The problem probably lies in how java streams interacts with octave process, but I can't seem to find any log that can explain to me what's happening.

Greetings,
Andrea Grassi

Re: Octave from Java

by Andrea Grassi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrea Grassi wrote:
Ok. Thank you anyway for your fast answer. I'll probably post a question in a separate post to see if anyone has solved this. The problem probably lies in how java streams interacts with octave process, but I can't seem to find any log that can explain to me what's happening.

Greetings,
Andrea Grassi
(answering myself..)

To those interested I've solved the above problem (even thought I don't know what was causing it).
To solve it, just use the "--interactive" switch when calling octave. This will forse the default "octave console" that doesn't have this problem.

If you used a BuffereReader (with readline) to read data beware that it will probably won't work well with this switch. Better read bytes.

Hope this will help someone :)

Andrea Grassi