Hi all, my current work involves interacting with MS Project files. The binary file format is pretty tedious to interact with. The best third party library I have found for reading the files is written in Java.
I have written a small test Java project that I have interoperating with a test Elixir project following guidance from this post The Erlangelist - Outside Elixir from @sasajuric.
The only problem is that the java program doesn’t die when the owning BEAM process dies or BEAM is terminated. This is discussed here: [erlang-questions] How do you kill an OS process that was opened with open_port on a brutal_kill?, and it sounds like it all relies on the program invoked by Port.open being “well-behaved” and shutting down if the stdin channel is killed.
I have trawled the Java docs and aside from realising how convoluted the process is for writing anything useful in Java (compared with Elixir), I haven’t found anything to help.
So the questions are:
- has anyone managed to get a well-behaved interop between Java and Elixir using Ports.
- If so, what does your main System.in reading code look like / how did you solve the problem of shutting down the java program without explicit termination commands from the Elixir side
- If not, what are the preferred options for Java interop. I am aware of JInterface but wanted to keep operational complexity down as far as possible and also minimise the amount of Java code.
I know this is probably a Java problem rather than an Elixir problem, but the Ports style interop for long-running processes through stdin/stdout does seem to be unique to Erlang/Elixir.
Edit: Only tries on Windows so far. Will year on Linux tomorrow.
Thanks!


















