在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

查看:131
本文介绍了在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将来停止将OS包含在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编写的,否则你会遇到编译问题。如果您使用外部第三方代码编译,即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天全站免登陆