Run native code via JNI / DLL or EXE?

We have a native application that can be accessed through JNI-> DLL or by calling EXE with command line parameters. What would be a better approach?

We will refer to this method approximately 100 times a day. Performance is not very important. This native application was developed by a group outside our company, so we are not too familiar with the code (although we have one).

The EXE route seems simpler and simpler (especially since we did not use much C). I am also going with JNI that you can destroy the JVM if your dll code has a memory leak or encounters some other problems.

+3
source share
2 answers

I highly recommend using the .exe approach.

  • If it works, you can update the .exe file
  • you will not suffer from memory leaks / crashes, etc.

The disadvantage is that you may need to analyze the .exe output to determine the results / state, etc., and if it is not intended for this, then it may be impractical (or impossible, even).

But, as a first approach, spawning .exe is the way to go. Remember to use stdout / err at the same time to avoid any problems with .exe freezes (a common problem if you need to believe SO).

+5
source

In this case, I would call the .exe file, mainly because an unstable application in this case cannot destroy the JVM.

.exe 100 .

, .dll API, , - .

+4

All Articles