Using a Java library in an Objective-C Mac app, and putting that app on the Mac App Store

故事扮演 提交于 2019-11-30 17:01:39

问题


I've been researching this problem for a while now, and have not yet arrived at a clear answer. I am writing a Mac OSX application that I intend to eventually put on the app store, and while I will be able to write most of it in Objective-C, I do need to call methods from a library that is only available in Java. I have 2 questions:

  1. From what I have read, it seems like JNI (using the Invocation API) is the only acceptable way of doing this (even though Apple deprecated the use of Java in Mac apps, and it isn't really acceptable). Is there any other way to do this?

  2. I have read that Apple does not allow Java apps on the Mac App store, but will it allow a mostly-native app that uses JNI to incorporate some Java classes? Since JNI can be used to "package" a Java VM with the app, it seems as though Apple's cessation of including Java with OSX in the future shouldn't be an issue.

Your insight will be much appreciated. Thanks.


回答1:


@Andrew - in a nutshell, if what you are doing is very simple (and doesn't touch libraries that use java.awt or java.swing) then GCJ /could/ work. I wouldn't recommend it at all really. The reason I say that is because GCJ doesn't support /many/ of the 'newer' java features and unless your java code is written targeting an oldish version of the JDK, you're going to run into compilation issues. If you compile with external 3rd party deps ie eclipse.anything, etc you will run into huge headaches.

I assume you have code that you have already written in java and want to leverage that code as a service to a much nicer (and native) objc UI. If that is the case, then honestly, I think you will find much more success and far less headache just biting the bullet and creating an objc codebase for your service layer :(

Of course there is the option of using the native mac ui as merely a thin client for a cloud-based distributed service layer (written in java ofc). But I'm not certain how/what apple thinks about thin clients to web based services in their app store.



来源:https://stackoverflow.com/questions/8623284/using-a-java-library-in-an-objective-c-mac-app-and-putting-that-app-on-the-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!