Is there a Cocoa or Objective-C api for Java?

I am a Java programmer, and I wanted to write such applications for Iphone. I started researching and found that I was looking at xmlvm..that's all right, but then xmlvm has HelloWorld.java with some UIWindow classes that I cannot find and cannot compile. In short, this is an api for Java, so I can compile xmlvm HelloWorld.java for Iphone. Here is the code: and I already compiled xmlvm with ant and I 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); } } 
+3
java iphone
Aug 12 '09 at 16:59
source share
3 answers

There is no java virtual machine on iphone - xmlvm should cross-compile Java code into an executable file for the phone.

edit 1: what is said coming from Java, you cannot find objective-C most of the shock to go to. It took me several months to find out that this comes from Java and C / C ++. Most iphone programming books (such as the pragmatic programmer) also provide some language information to get you started. This is a learning curve, but in the end I suspect it is much less disappointing, as it is a first-class language on the phone and is well supported by tools and documentation, etc.

edit 2: Looking at the webpage, it seems that xmlvm actually produces objective-C, which is related to the native xvmlm support base. I guess the next step is to compile the objective-C output using whatever tool chain you have - probably xcode, but if not, then some kind of gcc toolchain. In any case, the end result will be its own executable, not java bytecode. You install it just like any executable you create from objective-C.

+3
Aug 12 '09 at 17:06
source share

It looks like this question was posted 5 months ago, so it might be too late, but I imported this HelloWorld.java file into NetBeans and then added xmlvm.jar to my library path - soon to see what

 CGRect rect = screen.applicationFrame(); 

and

 title.setTextAlignment(UITextAlignment.UITextAlignmentCenter); 

Were broken. Fortunately, NetBeans autocomplete asked me to change the first to

 CGRect rect = screen.getApplicationFrame(); 

and second -:

 title.setTextAlignment(UITextAlignment.Center); 

Then I proceeded to compile the NetBeans project without errors. xmlvm compiled my received bytecode (.class files) into an iPhone / Xcode application, but then I couldn’t get THIS to compile due to inconsistencies in the automatically generated code.

XMLVM looks like a great project, which is very promising, but as it continues to update its code, their documentation lags, which leads to the first failure.

I have no logical explanation for the second.

0
Feb 03 '10 at 23:39
source share

I know that this is not exactly what you requested, but you can take a look at GWT. This makes your application based on web interfaces (which stores it in the store, so most people are not interested because they cannot make this cute iStore cash), but it allows you to program for web clients in a very natural Java language - - you can generally avoid using the "Web" protocols if you want to.

0
03 Feb 2018-10-03T00
source share



All Articles