Ask Your Question

Calling Sage from Java

asked 2019-01-02 20:11:12 -0600

CupOfCoffee gravatar image


I am looking for a way to call Sage functions, such as constructing Polyhedra, from Java (on Windows). In more detail, I want to do the following:

  1. Input to Sage from Java: P1 = Polyhedron(vertices = [[0,2], [-1,0], [1,0], [0,0]])
  2. Retrieve in Java the Sage output: P1.Hrepresentation()

It would be optimal if I could call Sage directly somehow, but if it's necessary, I think a python wrapper could also work. It would be very kind if somebody could point me in the right direction, maybe with code snippets, as I am very new to the Sage Environment.

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-01-08 07:55:10 -0600

PatHooper gravatar image

updated 2019-01-08 08:00:09 -0600

eric_g gravatar image

Hello CupOfCoffee,

First some caveats: I don't use windows and I've never tried to connect sage to java.

I think you should be able to run programs in Java with ProcessBuilder ( I expect you'd need to pass some parameters to sage to get it working correctly. Here are some relevant links:

Then I would think you would want to pass and read commands to Sage through input/output to the process. There is a StackOverflow question addressing this here:

I imagine if you want to just do what you are suggesting, this wouldn't be too bad, but if you want to do something more complex, dealing with the input/output could be a pain.

Best, Pat

PS. Sorry for mangling the links. The post wouldn't go through without it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2019-01-02 20:11:12 -0600

Seen: 57 times

Last updated: Jan 08