Java to iOS Objective-C translation tool and runtime

If you work on a mobile app and you’re planning on developing it on Android and iOS, it may be less work for you to write it on Android first. Google recently released a new tool that makes porting Java code to iOS much easier.
The project (j2objc) can be found here.

To give the program a quick test run, I ran it using this Java file:




public class hello {
public static void main(String[] args) {
System.out.println("To Objective C we go!");

After running the above code using j2objc, I received two files (as expected): the header file, hello.h, and the source file, hello.m. The source file looks like this:

// Generated by the J2ObjC translator. DO NOT EDIT!
// source:
// Created by Isaac on 10/18/12.

#import "IOSObjectArray.h"
#import "hello.h"

@implementation hello


int main( int argc, const char *argv[] ) {
int exitCode = 0;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
IOSObjectArray *args = J reEmulationMainArguments(argc, argv);

NSLog(@"%@", @"To Objective C we go!");

[pool release];
return exitCode;

J2Objc certainly has to make a few decisions when converting between the two languages. One is seen above, as System.out.printLn is converted to NSLog. Currently J2Objc can convert much of Java, including things like reflection and anonymous classes in Java. I imagine these kinds of decisions are made through the program.

Although the library can’t touch any specific Java code related to the Android APIs, it can handle anything written in pure Java. The tool certainly has potential, especially for converting standard java classes directly to their Objective C equivalent.

Reference: A Reason to Write Android Apps First from our JCG partner Isaac Taylor at the Programming Mobile blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

3 Responses to "Java to iOS Objective-C translation tool and runtime"

  1. harrita s says:

    Hi! i just want to know how to start with this. PLS PLS PLS help me.

    I am having a completed java projet. and i downloaded j2objc also. i has some folders like include, lib, man and two j2objc file. I just wan to know how to start? I know objective c xcode. so pls help me to start. where i should put my file.

  2. Crushman says:

    This seems to only be able to translate Very generic java classes. have you been successful in translating more complicating java code? for example java code that uses jar file dependancies.

  3. yodannco says:

    I guess it only convert the java code u write, but it cant convert the android API. still need a little bit touching up manually to fully convert to Obj-C. But better than nothing for the moment.

Leave a Reply

3 × = twelve

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: