Over a million developers have joined DZone.

HelloWorld with Java, iOS and RoboVM

DZone's Guide to

HelloWorld with Java, iOS and RoboVM

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

Ever since native iOS applications have been developed with Objective C, there has been a surprising emergence of alternatives to using Objective C as the language to develop these applications. For example, just to name a few:

The latest one that I have come across is RoboVM, that allows for iOS applications to be written and deployed using the Java language. This post will go through the steps of getting a very simple application up and running with RoboVM and Java.

Here are the pre-requiestes:

Firstly, within Eclipse, install the RoboVM plugin, under Help, Install New Software, http://download.robovm.org/eclipse/. This will need to restart the IDE.

With the plugin installed, you can create a new project. Select the'RoboVM iOS Project' option.

Just use 'HelloWorld' as the project nameMain classApp name and App id. It should look like the screenshot below.

For some reason, when I use the wizard, the Main Class does not get created, so this needs to be done manually. So create a class calledHelloWorld.

Put the following contents in the HelloWorld class.

import org.robovm.apple.foundation.NSAutoreleasePool;  
import org.robovm.apple.foundation.NSDictionary;  
import org.robovm.apple.foundation.NSString;  
import org.robovm.apple.uikit.UIApplication;  
import org.robovm.apple.uikit.UIApplicationDelegateAdapter;

public class HelloWorld extends UIApplicationDelegateAdapter {

    public boolean didFinishLaunching(UIApplication application,
            NSDictionary<NSString, ?> launchOptions) {
        return true;

    public static void main(String[] args) {
        NSAutoreleasePool pool = new NSAutoreleasePool();
        UIApplication.main(args, null, HelloWorld.class);


Here we are extending the UIApplicationDelegateAdapter which is RoboVM version of the UIApplicationDelegate. We have a main method in the class which launches the application.

What we will do now is override the didFinishLaunching method to create an UIWindow and an UIlabel. To achieve this, add the following details to the method.

    public boolean didFinishLaunching(UIApplication application,
            NSDictionary<NSString, ?> launchOptions) {
        UIWindow window = new UIWindow(UIScreen.getMainScreen().getBounds());
        UILabel label = new UILabel(new CGRect(50, 50, 100, 50));
        label.setText("Hello World");
        return true;

Most of the code above should be pretty self explanatory. The arguments into the construction of the CGRect class are the x and y co-ordinate followed by the label's width and height.

If you right click the project and select Run as/iOS Simulator App (iPhone). You should be presented with an iOS simulator with a green screen with the text "Hello World". Something like the screenshot below.

If you have reached this point, it means your environment has been setup correctly and you should be able to start developing iOS applications with Java.

Here are some references for more information. I hope this post has been useful in showing you the first steps to iOS development using Java.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.


Published at DZone with permission of Ricky Yim, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}