在 Objective-C Mac 应用程序中使用 Java 库,并将该应用程序放到 Mac App Store [英] Using a Java library in an Objective-C Mac app, and putting that app on the Mac App Store

查看:25
本文介绍了在 Objective-C Mac 应用程序中使用 Java 库,并将该应用程序放到 Mac App Store的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究这个问题已经有一段时间了,还没有得出明确的答案.我正在编写一个 Mac OSX 应用程序,我打算最终将它放在应用程序商店中,虽然我将能够用 Objective-C 编写其中的大部分内容,但我确实需要从仅在 Java 中可用的库中调用方法.我有两个问题:

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. 从我读到的内容来看,它看起来像 JNI(使用 Invocation API) 是唯一可以接受的方式(尽管 Apple 不赞成在 Mac 应用程序中使用 Java,但它并不是真正可以接受的).有没有其他方法可以做到这一点?

  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?

我了解到 Apple 不允许在 Mac App Store 上使用 Java 应用程序,但它是否允许使用 JNI 来合并一些 Java 类的主要本地应用程序?由于 JNI 可用于将 Java VM 与应用程序打包"在一起,因此 Apple 在未来停止将 Java 与 OSX 结合使用似乎不成问题.

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.

推荐答案

@Andrew - 简而言之,如果您正在做的事情非常简单(并且不涉及使用 java.awt 或 java.swing 的库)那么GCJ/可以/工作.我根本不会推荐它.我这么说的原因是因为 GCJ 不支持/许多/较新"的 Java 功能,除非您的 Java 代码是针对旧版本的 JDK 编写的,否则您将遇到编译问题.如果您使用外部 3rd 方 deps(即 eclipse.anything 等)进行编译,您将遇到巨大的麻烦.

@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.

我假设您有已经用 Java 编写的代码,并且希望利用该代码作为服务来获得更好(和本机)的 objc UI.如果是这种情况,那么老实说,我认为只要咬紧牙关并为您的服务层创建一个 objc 代码库,您会发现更多的成功和更少的头痛:(

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 :(

当然,也可以选择使用原生 mac ui 作为基于云的分布式服务层(用 java ofc 编写)的瘦客户端.但我不确定苹果如何/如何看待他们的应用商店中基于 Web 的服务的瘦客户端.

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.

这篇关于在 Objective-C Mac 应用程序中使用 Java 库,并将该应用程序放到 Mac App Store的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆