C API call from Groovy

I know that it is better to use Python to call Posix and the Win API, but I would like to know if there is a not so painful way to call the C API from Groovy, or at least with Java.

+3
source share
2 answers

The official way to invoke your own platform (implicitly, all C / C ++ code) from Java is JNI . I would not call it "not very painful."

You can look at SWIG to generate most of the nasty code for you, I used it a couple of times some of my own C code with some success. I was forced to "process-out" some of my code to make it Java-readable, however.

An option that I read about, but was never used personally, by JNA . It looks smaller than JNI, but I can't vouch for it.

All of these solutions are Java oriented, but I don’t understand why you couldn’t use them in any JVM hosted language.

+3
source

If this is the COM library you are trying to call, Scriptom is the Groovy library that can do the trick.

0

Source: https://habr.com/ru/post/1712220/


All Articles