First time here? Check out the FAQ!

Ask Your Question
2

Calling Sage from Java

asked 6 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 6 years ago

PatHooper gravatar image

updated 6 years ago

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.

Preview: (hide)
link

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: 6 years ago

Seen: 965 times

Last updated: Jan 08 '19