# Killing java processes started from Port.open

**URL:** <https://forum.elixirforum.com/t/killing-java-processes-started-from-port-open/31119>\
**Category:** Questions\
**Tags:** java, interoperability\
**Created:** [April 30, 2020, 9:33am UTC](https://forum.elixirforum.com/t/killing-java-processes-started-from-port-open/31119 "2020-04-30T09:33:04Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mindok](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mindok/32/13538_2.png) [@mindok](https://forum.elixirforum.com/u/mindok)\
**Post date:** [May 1, 2020, 1:34am UTC](https://forum.elixirforum.com/t/killing-java-processes-started-from-port-open/31119/6 "2020-05-01T01:34:11Z")

</div>

OK, problem exists between chair & keyboard. My main loop was badly behaved. I stripped it back to the most basic stdin read loop and it terminates ok. Time to start building it up again and see where it fails.

For reference, here’s a minimal Java program that works nicely over ports, terminating when the process or BEAM terminates (including brutally killing from Windows task manager):

```java
package com.thing;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        int ch;
        while(true) {
            ch = System.in.read();
            if (ch == -1) {break;} // This is the EOF signal in Java
            if (ch == 'q') {break;}
            if (ch == 't') {System.out.println("tasks");}
            System.out.println(" got " + ch + " - " + (char)ch);
        }
    }
}

```

---

_[View the full topic](https://forum.elixirforum.com/t/killing-java-processes-started-from-port-open/31119)._
