I wanted to perform some actions in my Java program whenever a particular interface comes up (network interface ppp0 e.g.). However I figured out it was way too clumsy to keep polling the interface to verify its status.
After finding out
if-up.local file in Linux, now I can run a bash script whenever the interface comes up. Works fine, however considering my running Java program, how can I make this script interact with my Java code?
I am considering the following options:
- Write a listening socket and from this script send message to this Java socket.
- Invoke a C program, and through JNI run my java code.
I am looking for intuitive and less resource intensive approach.