Ask Your Question
2

Calling Sage from Java

asked 2019-01-03 03:11:12 +0100

CupOfCoffee gravatar image

Hello,

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
2

answered 2019-01-08 14:55:10 +0100

PatHooper gravatar image

updated 2019-01-08 15:00:09 +0100

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 (https://docs.oracle.com/javase/6/docs...). 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: https://stackoverflow.com/questions/1...

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

Stats

Asked: 2019-01-03 03:11:12 +0100

Seen: 895 times

Last updated: Jan 08 '19