Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Java library from Objective C on Mac

I want to create native Mac OS X application using Cocoa + Objective C but I need to connect to proprietary data source, and for this, owner of the data source only provides Java library. So I need to somehow import this Java library into my project and call functions on its Java classes.(Or create java wrapper around this library and then call my wrapper from objective-C).

Now, how can I do this? Quick google search leads me to JNI but I haven't found any good and actual(current) article/tutorial. I would really need some HOW TO article, how to load this java library, start VM if needed, and how to create java objects and call functions on them. Really something simple and I can move from there. Thanks.

Just to clarify, I repeat: I WANT to call Java functions from Objective-C, I do NOT want to call native functions from Java.

like image 877
Michal Avatar asked Nov 30 '09 21:11

Michal


1 Answers

You're probably looking for the Invocation API, a little-known corner of Java Native Interface (JNI) which allows you to load the Java runtime in-process.

That said, you might have an easier time of it with a Java service application that communicates with your Objective-C application over network sockets.

like image 61
Jeffrey Hantin Avatar answered Nov 06 '22 07:11

Jeffrey Hantin