I have a Java (JVM) library that I would like to use in my native code. What is the best way to call JVM functions from native? Do I have to use JNI to make it work. Or is there a better solution?
c
Chilli
05/05/2020, 9:02 AM
If you need a Java library, why would you use Native?
p
Patrick
05/05/2020, 9:07 AM
Because we are creating a Windows app that is relying on the WIN32 API and we already have a couple of C interops set up. We have the problem that a client wants a specific Java library that is not available for native. It wouldn't make sense for us to port the whole project to JVM just so the client can use that one library.
c
Chilli
05/05/2020, 9:09 AM
Well — the easiest way might be just choosing another library — for C for example. If you really need one for Java, there might be a problem
h
Hauke Radtki
05/05/2020, 9:18 AM
I have not tried it myself but the GraalVm offers "polyglot" support, and claims to allow to interoperate any number
p
Patrick
05/05/2020, 11:48 AM
Yeah of course the best would be to have a Kotlin or C library available, but unfortunately that is not the case.