如何用 Java 开发 iPhone 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2050943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can one develop iPhone apps in Java?
提问by Brendan Lesniak
In my computer science class, I have completed all my projects; So my teacher thought it'd be a good idea to develop IPhone apps. The only problems is that the class is taught in java, and IPhone apps are written in Objective-C.
在我的计算机科学课上,我完成了我所有的项目;所以我的老师认为开发iPhone应用程序是个好主意。唯一的问题是课程是用java教授的,而iPhone应用程序是用Objective-C编写的。
I was wondering if anyone has developed applications in Java, with XMLVM.
我想知道是否有人用 XMLVM 用 Java 开发过应用程序。
This compiler (supposedly) converts java byte code into Objective-C (without needing an apple computer or knowledge of Objective-C). Is this correct?
这个编译器(据说)将java字节码转换成Objective-C(不需要苹果电脑或Objective-C知识)。这样对吗?
http://www.xmlvm.org/overview/
http://www.xmlvm.org/overview/
Here is a code example of Java code being used on an IPhone:
以下是在 iPhone 上使用的 Java 代码示例:
采纳答案by Amir Afghani
If you've completed your other projects, why not take the time to learn Objective-C? There is a ton of material out on the web to help you get started. Honestly, it won't be that hard and learning to do somememory management will be a great learning exercise. Have you programmed in C before?
如果您已经完成了其他项目,为什么不花时间学习 Objective-C?网络上有大量材料可以帮助您入门。老实说,这不会那么难,学习进行一些内存管理将是一个很好的学习练习。你以前用 C 编程过吗?
Most cross compilers won't do a great job in converting your code, and debugging your project may become much more difficult if you develop them this way.
大多数交叉编译器在转换您的代码方面不会做得很好,如果您以这种方式开发它们,调试您的项目可能会变得更加困难。
回答by Justin Niessner
回答by deanvmc
I think your teacher sent you down the wrong path.
我认为你的老师让你走错了路。
This is a classic example of trying to put a square peg into a round hole. The best way to develop for the iPhone is with the iPhone SDK and objective C. The best way to develop for Andriod is Java and the Android SDK. The best way to develop for WinMobile is C#/VB and the .Net Framework.
这是尝试将方钉插入圆孔的经典示例。为 iPhone 开发的最佳方式是使用 iPhone SDK 和目标 C。为 Andriod 开发的最佳方式是 Java 和 Android SDK。为 WinMobile 开发的最佳方法是 C#/VB 和 .Net Framework。
As you can see each has their own "best" SDK. Since you are only learning Java I would second the suggestion to play around with Java and Android.
正如您所看到的,每个人都有自己的“最佳”SDK。由于您只学习 Java,因此我建议您使用 Java 和 Android。
回答by Jacek
You need to know at least basics of Objective-C to develop for iPhone. However, it is possible to use C++ classes.
您至少需要了解 Objective-C 的基础知识才能为 iPhone 进行开发。但是,可以使用 C++ 类。
As far as I know Adobe is working on building Flex/Flash applications for iPhone. Read more here: http://theflashblog.com/?p=1513
据我所知,Adobe 正在为 iPhone 构建 Flex/Flash 应用程序。在此处阅读更多信息:http: //theflashblog.com/?p=1513
回答by Thorbj?rn Ravn Andersen
You can't.
你不能。
Note however that Monotouch allows you to develop in C# instead of Objective-C. http://monotouch.net/
但是请注意,Monotouch 允许您使用 C# 而不是 Objective-C 进行开发。 http://monotouch.net/
回答by Krusty
You can try iSpectrum ( get it at http://www.flexycore.com) You'll be able to develop and debug your Java apps in Eclipse. You'll still need a Mac and XCode to launch it on the simulator, or install it on the real device, though. But you won't have to actually use XCode editor. Plus you can use it for free if you're planning to work on an open source project.
您可以尝试 iSpectrum(从http://www.flexycore.com获取)您将能够在 Eclipse 中开发和调试您的 Java 应用程序。不过,您仍然需要 Mac 和 XCode 才能在模拟器上启动它,或者将其安装在真实设备上。但您不必实际使用 XCode 编辑器。此外,如果您计划从事开源项目,则可以免费使用它。
回答by Charles
Perhaps you should consider Android applications instead of iPhone applications if you really want to develop in Java for smartphones. Android natively uses Java for it's applications; so perhaps this might be a better option?
如果你真的想用 Java 为智能手机开发,也许你应该考虑 Android 应用程序而不是 iPhone 应用程序。Android 在其应用程序中原生使用 Java;所以也许这可能是一个更好的选择?
As for iPhone, I would recommend you to look into Obj-C or C/C++ depending on the type of applications you want to make. Should be fun to dabble into a new language! :)
至于 iPhone,我建议你根据你想要制作的应用程序类型来研究 Obj-C 或 C/C++。涉足一门新语言应该很有趣!:)
回答by Naijaba
If you plan on integrating app functionality with a website, I'd highly recommend the GWT + PhoneGap model:
如果您打算将应用程序功能与网站集成,我强烈推荐 GWT + PhoneGap 模型:
http://blog.daniel-kurka.de/2012/02/mgwt-and-phonegap-talk-at-webmontag-in.htmlhttp://turbomanage.wordpress.com/2010/09/24/gwt-phonegap-native-mobile-apps-quickly/
http://blog.daniel-kurka.de/2012/02/mgwt-and-phonegap-talk-at-webmontag-in.html http://turbomanage.wordpress.com/2010/09/24/gwt-phonegap -native-mobile-apps-quickly/
Here's my two cents from my own experience: We use the same Java POJOs for our Hibernate database, our REST API, our website, and our iPhone app. The workflow is simple and beautiful:
这是我根据自己的经验得出的两分钱:我们对 Hibernate 数据库、REST API、网站和 iPhone 应用程序使用相同的 Java POJO。工作流程简单而美观:
Database ---1---> REST API ---2---> iPhone App / Website
数据库---1---> REST API ---2---> iPhone 应用程序/网站
- 1: Hibernate
- 2: GSON Serialization and GWT JSON Deserialization
- 1:休眠
- 2:GSON序列化和GWT JSON反序列化
There is another benefit to this approach as well - any Java code that can be compiled with GWT and any JavaScript library become available for use in your iPhone app.
这种方法还有另一个好处——任何可以用 GWT 编译的 Java 代码和任何 JavaScript 库都可以在您的 iPhone 应用程序中使用。
回答by Chen
take a look at codenameone.com project, it's a cross platform mobile framework where the ui part is a fork of LWUIT. This project leverage xmlvm to translates the java bytes code to Objective C
看看 codenameone.com 项目,它是一个跨平台的移动框架,其中 ui 部分是 LWUIT 的一个分支。该项目利用 xmlvm 将 java 字节代码转换为 Objective C
回答by technoSesh
I'm answering this question 2 years down the line and I muststressthat I did have pretty much the same problem as you did. However I'm so happy that Android has evolved into what it is today.
我在 2 年后回答这个问题,我必须强调,我确实遇到了与您几乎相同的问题。不过我很高兴 Android 已经发展成为今天的样子。
Having said that, I do regret that I did not learn C/C++while I could have and I don't want to blame my teachers for it cos where was my brain when the time was right?
话虽如此,我确实后悔没有在我可以学习的时候学习C/C++,而且我不想为此责怪我的老师,因为我的大脑在合适的时候在哪里?
I'm sunk in Java today and I'm glad that I did not make the mistake of learning too many languages and being less productive... HoweverI did learn HTML5which really made things a lot easier, maybe someday, I might get motivated to learn C/C++ . Or if I get an Apple mac at a real throw-away price, I might learn Objective-C :)
我今天沉迷于 Java,我很高兴我没有犯下学习太多语言和效率低下的错误……但是我确实学习了HTML5,这确实让事情变得容易多了,也许有一天,我可能会明白有动力学习 C/C++ 。或者,如果我以真正的一次性价格获得 Apple mac,我可能会学习 Objective-C :)