是否有Java的Cocoa或Objective C api? [英] Is there an Cocoa or Objective C api for Java?

查看:27
本文介绍了是否有Java的Cocoa或Objective C api?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java程序员,所以我想开始编写Iphone的应用程序.我开始研究,发现自己看着xmlvm ..一切都很好,但是xmlvm有了一个HelloWorld.java,其中包含一些我找不到和无法编译的UIWindow类.缺少它的是Java的api,因此我可以为Iphone编译xmlvm的HelloWorld.java.这是代码:并且我已经用ant编译了xmlvm,并且在我的类路径中有xmlvm.jar?

I'm a Java programmer and i wanted to get into writing so apps for the Iphone. I started to research and found myself looking at xmlvm..that all good, but then xmlvm has a HelloWorld.java with some UIWindow classes that i can't find and can't compile. Short of it is where is the api for Java so i can compile xmlvm's HelloWorld.java for the Iphone. Here's the code: and i've already compiled xmlvm with ant and have xmlvm.jar in my classpath so??

import org.xmlvm.iphone.*;

public class HelloWorld extends UIApplication {

    public void applicationDidFinishLaunching(UIApplication app) {
        UIScreen screen = UIScreen.mainScreen();
        CGRect rect = screen.applicationFrame();
        UIWindow window = new UIWindow(rect);

        rect.origin.x = rect.origin.y = 0;
        UIView mainView = new UIView(rect);
        window.addSubview(mainView);

        UILabel title = new UILabel(rect);
        title.setText("Hello World!");
        title.setTextAlignment(UITextAlignment.UITextAlignmentCenter);
        mainView.addSubview(title);

        window.makeKeyAndVisible();
    }

    public static void main(String[] args) {
        UIApplication.main(args, HelloWorld.class);
    }

}

推荐答案

iPhone上没有Java VM-xmlvm必须将Java代码交叉编译为电话的可执行文件.

There is no java VM on the iphone - xmlvm must cross-compile the java code into an executable for the phone.

edit 1:据说来自Java,您可能不会发现目标C迁移到它会带来很大的震撼.我花了几个月的时间从Java和C/C ++中学习它-大多数关于iphone编程的书(例如,实用的程序员的书)也提供了一些语言背景,以帮助您入门.这是一个学习曲线,但最终我怀疑它会成为电话上的一流语言,并且得到工具和文档等的良好支持,因此令人沮丧.

edit 1: that said coming from Java, you may not find objective-C that much of a shock to migrate to. It took me a few months to learn it coming from Java and C/C++ - most of the books about iphone programming (e.g. the pragmatic programmer's one) also give a little background on the language to get you started. It is a learning curve but ultimately I suspect a lot less frustrating as it the first-class language on the phone and well supported by tools and documentation etc.

edit 2:乍一看该网页,看起来xmlvm产生的实际上是Objective-C,与本机xvmlm支持框架链接在一起.我假设下一步是使用您拥有的任何工具链来编译Objective-C输出-可能是xcode,但如果没有的话,则是一些gcc工具链.无论如何,最终结果将是本机可执行文件,而不是Java字节码.您将像从Objective-C生成的任何可执行文件一样进行安装.

edit 2: From a glance at the webpage, it looks like what xmlvm produces is actually objective-C, linked against a native xvmlm support framework. I assume the next step is to compile the objective-C output using whatever toolchain you have - probably xcode but if not then some gcc toolchain. Anyway the end result is going to be a native executable not java bytecode. You'll install that just like any executable you build from objective-C.

这篇关于是否有Java的Cocoa或Objective C api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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