-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling Java method from C? #235
Comments
Please take this discussion to the mailing list, not the issues list. Presumably you're running some Java code already in order to have a "logger". Have that call make a call to your C code to provide it a function, say "void register_callback(void (logger)(const char))". Map that function using JNA, e.g.
Closes #235. On May 24, 2013, at 11:55 AM, Paolo Bolzoni wrote:
|
Motifivation: netty-jni-util 0.0.2.Final is incompatible with static linking. netty-jni-util 0.0.3.Final adds static linking compatibility. Modifications: Bump netty-jni-util to version 0.0.3.Final and update to its new API which requires the caller to manage packagePrefix. Result: Using latest version of netty-jni-util and support static linking compatibility.
Is it possible to call a Java method from C code?
In the project I am working on, some calculation are made in C code and I would like to call the Java logger to give info about how it is going.
I sought around and I read this:
""You can.[Call a Java method from C] With a callback class that corresponds to a function pointer on the C side. void register_callback(void (*)(const int)); would be mapped to public static native void register_callback(MyCallback arg1); where MyCallback is an interface extending com.sun.jna.Callback with a single method void apply(int value);""
Unfortunately I do not have much experience with Java (I am the one writing in C) and I did not understand much. It seems there is way to treat a Java method as a function pointer, it would be great.
Can anyone explain how-to, or point me to the manual?
Thanks
The text was updated successfully, but these errors were encountered: