How to migrate external procedure from Oracle Listener to Postgres
You can rewrite it as a normal C or PL/Java function in PostgreSQL.

If it is important for you to run the function in a separate process, give PL/Container a try.