Home » Android » Android Core » Java to iOS Objective-C translation tool and runtime

About Isaac Taylor

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: hello.java
// 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 our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
harrita s
harrita s
9 years ago

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 xxx.java file.

8 years ago

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.

8 years ago

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.

1 year ago

I am having a completed java projet. and i downloaded j2objc also. i has some folders like include, lib, man and two j2objc file

1 year ago

How can I start with this

1 year ago

Good explanation. Do we have videos for the same?