NatJ on desktop platforms

Are there any plans to port NatJ to run on OSX? You can use java-objc-bridge (which utilizies JNA under the hood) to access native objective-c APIs via Java (or write your own shim using JNA), but it’s definitely not as comprehensive as NatJ’s objective-c support. Making it available via maven central for general use across all platforms would be awesome.

I’m mostly interested in using NatJ for objective-c, but since it does also support the c runtime it could also be used as a JNA alternative as well for use on Windows/Linux as well.

Dear kevin-vf,

NatJ supports iOS, macOS (x86-64), Windows (i386/x86-64) and Linux (i686/x86_64) and Android (armeabi-v7a, arm64-v8a, mips, mips64, x86, x86_64). Though please keep in mind, that Windows (i386), Linux and Android implementations are not heavily tested.

Best Regards,
Kristóf

Note: some of our tools (device launcher, NatJGen, etc.) already uses NatJ on macOS and Windows.

Ahh, I didn’t realize this; I had searched maven central and jcenter and didn’t find anything, and since the moe-gradle plugin handles injecting the dependencies on iOS I didn’t realize this. How does one use natj for a non-iOS project? I couldn’t find any anything for org.multi-os-engine or moe via jcenter’s website. I notice the natj native libs under tools for macosx and windows, but there’s no native libraries on linux.

Is there any documentation on how one would set this up for a multi-platform project? Glancing at natj’s build.gradle makes me assume org.moe:natj-api:1.1.0 but that doesn’t turn up anything, and all the moe build tools seem to refer to a external jar for the dependency. https://doc.multi-os-engine.org/multi-os-engine/7_creating_db_app/2_part2/part2.html makes reference to downloading the jar from the project’s github releases, but I can’t find anything of the sort. Do I need to build all the native libraries and the api jar myself?

Hi Kevin,

currently the only option to use NatJ outside of MOE is to build it yourself. We plan to change it down the road, so NatJ is distributed separately from the rest of MOE, but did not get around to it yet.

Best Regards,
Gergely

Thanks for the information; I was able to build a copy of NatJ using the 1.2.5 moe branch.

However, I’m running into an issue when I try and use wrapnatjgen to generation a jar for the osx foundation framework. I cd into ~/.moe/moe-1.2.5/tools and run the tool (which was downloaded from using the IDEA plugin), follow the instructions from https://doc.multi-os-engine.org/multi-os-engine/6_natj/natjgen_binding_generator/NatJGen_Binding_Generator.html but the tool churns away for a while, then finally exits with an error:

java.io.IOException: An error occured during process of bindings compilation
at org.moe.natjgen.cli.executor.AbstractLinkExecutor.execute(AbstractLinkExecutor.java:234)
at org.moe.natjgen.cli.Main.main(Main.java:44)

The only output before this are just the usual “Creating compilation unit at…” messages, with the last file name before the error being applicationservices/opaque/ATSFontNotificationInfoRef.java. Is there a way to get more detailed output? --help doesn’t list anything to increase the log level or anything useful.

For reference, I’m running the following command:

java -jar wrapnatjgen.jar --headers /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ --framework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework --output-file-path=~/foundation.jar

I added --headers since I noticed some missing header includes for some of the C runtime, but I originally ran the command without it and had the same error.

I have Xcode 8.2.1, running on OSX 10.11.6, incase that’s of any value.

Dear kevin-vf,

we generate SDK code differently. For reference please check out how we generate bindings for iOS:

https://github.com/multi-os-engine/moe-core/tree/master/moe.apple/moe.platform.ios

Note: there will be significant updates to UPDATE_IOS_BINDING.md when MOE-1.3.0-beta-2 is released.

Best Regards,
Kristóf