We have a native app that we can access via JNI->DLL or by invoking an EXE with command line parameters. Which would be the best approach?
We will be invoking this method about 100 times a day. Performance isn't super important. This native app was developed by a group outside of our company so we are not too familiar with the code (though we do own it).
The EXE route seems easier and more straightforward (especially as we haven't used a lot of C). Also I gather with JNI you can crash your JVM if if your DLL code has a memory leak or encounters some other troubles.
I would strongly recommend the .exe approach.
The downside is that you may have to parse the .exe output to determine results/status etc., and if it's not designed for this, then this might be impractical (or impossible, even).
But as a first approach, spawning the .exe is the way to go. Don't forget to consume the stdout/err concurrently to avoid any .exe hanging problems (a common problem, if SO questions are to be believed).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With