In this guide, we will get to know everything about iOS app development with Java.
We will discuss the development process, technology involved, prerequisites and general FAQs for building apps for iPhone/iPad using Java.
Here are the major topics we’ve covered in this Java iOS app development guide.
Jump To Topic
Java is one of the most popular programming languages around the world for everything from mobile development to enterprise and server-side applications.
Being a general-purpose, object-oriented and cross-platform programming language, Java enables developers Write Once, Run Anywhere (WORA), meaning that a Java program could be developed on any device and can be expected to run on any hardware that has a JVM (Java Virtual Machine).
Before we delve any further on how to code in Java for building iOS apps, we need to understand two most common approaches for app development…
Native App Development
Developing a platform specific app using its native programming language is called native app development.
For example, using Java or Kotlin for Android and Swift or Obj-C for iOS.
Cross-Platform App Development
Developing apps using a single codebase that runs on multiple platforms refers to cross-platform app development.
Some common cross-platform frameworks include Flutter, React Native and Codename One.
iOS App Development
How are iOS apps made?
If you want to get into writing iOS apps for the iPhone, iPads etc, you have two options:
Code native iOS apps with Swift or Objective-C
If you want to develop native apps for iOS, the official iOS SDK combined with Xcode allows you to write apps with Swift or Obj-C.
Use a cross-platform framework
For those who don’t know or want to learn Swift, a suitable cross-platform app development framework can compile your code to native iOS executable.
Java vs Swift
What language to choose for iOS development?
Java is the native language for Android while Swift is the native language for Apple devices (iOS, macOS, watchOS, tvOS).
Both Java and Swift are static-type, object oriented and compiled programming languages.
Swift is one of the newer programming languages while Java has been around for years.
Difference between Java and Swift:
Java is not platform dependent
Swift is dependent on iOS and MacOS
Java is verbose and has complex syntax and code readability
Swift has easy syntax and code readability
Modern Java is quite fast. A well optimized Java app can be as fast as a native app
Swift is fast as it was built with performance in mind for Apple ecosystem
Java is more secure compared to Swift with its byte-code verifier, JVM and security API's
Swift was designed to be memory safe. Swift can call Objective-C code which makes it prone to overflows
Both Java and Swift are quite different in terms of methods, syntax, code usability etc.
Swift is obviously a preferred choice to develop apps specifically for the Apple ecosystem while Java is a preferred choice for Android development or cross-platform reusability.
Java on Apple Hardware
Why doesn't Apple support Java?
By now you might be thinking ‘if Java code can run on any platform, why can’t Java run on iOS?’
Java can run on any platform that has a compatible Java Virtual Machine (JVM). Since Apple doesn’t support JVM for iOS, Java can’t run on iPhones and iPads.
Apple makes sure that only Swift and Objective-C has 100% vendor support on iOS by forbidding alternative runtimes from being deployed on it.
Develop iOS apps with Java
iOS app development using Java is easier than you think.
Everything we have discussed so far is not to say that you cannot develop iOS apps in Java.
The only way to develop iOS apps in Java is to have a compiler that will compile your Java code down to native iOS binary.
If you’re not using Codename One yet, then sign up now:
How Does It Work?
Underlying technology that enables Codename One to develop iOS apps with Java.
Native iOS development requires a Mac with Xcode. To make matters worse, Apple makes changes to their tools on a regular basis.
Codename One has a built-in simulator when running and debugging an app. For native iOS builds, Codename One build cloud uses Macs running Xcode (the native Apple tool) to build the app.
This removes the need to install/update complex toolchains and simplify the process of building a native iOS app.
The process works seamlessly and makes Codename One apps native as they are literally compiled by the native platform.
Java bytecode is dynamically translated to a native iOS Xcode project and seamlessly compiled to a native binary. This binary can be installed on iOS devices or uploaded to App Store.
What you need to get started.
To run and build the project, you should be running a modern version of Mac OS, Windows, or Linux with JDK 11 installed.
You don’t need to install anything other than the Codename One plugin. You can work with Mac, Windows or Linux and everything should “just work”.
Let’s dig in.
Tutorial to walk you through the steps of building a Hello World app.
Codename One initializer
Open in IDE
Develop & Debug App
Create iOS Build
Step 1: Generate a new project with Codename One initializr
The easiest and quickest way to create a new project is to use the Codename One initializr.
This online tool will allow you to choose from a growing selection of project templates in Java or Kotlin, and download a starter project that you can open in your preferred IDE or build directly on the command-line using Maven.
• Enter a Package and Main Class for your app. The Package will be used both for your App ID, when you submit your app to the App Store, and for your Maven project’s
groupID. The Main Class is the name of the
main Java class for your app.
• Press Download and save the project as a .zip file.
• After the download completes, extract the zip file.
Step 2: Open the project in your preferred IDE
You can run the project directly from the command-line or you can open it in your preferred IDE (e.g. IntelliJ or NetBeans).
For this tutorial, I’m going to use IntelliJ.
As this is a Maven project, IntelliJ can open this project and work with it natively without requiring any special plugins.
• Open the extracted project in IntelliJ (or your preferred IDE).
• Press the green icon to run the app in the simulator.
• Wait while Maven downloads the build dependencies. It will open the Codename One simulator with the simple Hello World app.
Step 3: Develop & Debug your app
If you run this project in the Codename One Simulator without making any modifications to the app, it will look something like this:
The simulator makes it easy to develop and debug your app without having to build and deploy to a real device.
It includes a number of useful features aimed at streamlining the development process.
Generally, you would work exclusively in the simulator until you have a near finished product that you want to share with your beta-testers.
Step 4: Build the project for iOS
Finally, we can build a native app for iOS by running the Xcode iOS project target.
When building for iOS, you can either build locally or via build server.
With Codename One build server, iOS apps can be built on Windows, Linux, or Mac with no special requirements beyond Maven and the JDK. All you need is a free Codename One account.
For iOS builds, there are two build targets that use the build server:
• iOS Debug Build (for testing and debugging)
• iOS Release Build (to submit to the iOS App store)
• Click on the configuration menu in the upper right toolbar, and select Build Server > iOS Debug Build/iOS Release Build as shown below:
• Press the button to build the project.
• After you submit the build, you can track and install them via Build Server, Control Center or the Android Build app.
Local iOS builds
The Local iOS build target generates an Xcode iOS project that you can open and build directly in Xcode.
• Click on the Configuration menu in the upper right toolbar, and select Local Builds > Xcode iOS Project as shown below:
• Press the button to build the project.
• If all goes well, the project will be found in the
• You can proceed to open the Xcode project (.xcworkspace file) in Xcode, and build the project.
TLDR (Too Long Didn't Read)
All of the above is shown in this tutorial by Steve Hannah
In this quick video, Steve Hannah uses the bare-bones Java project generated by Codename One initializr, which he’s running in IntelliJ, to build for iOS.
He also gives a brief tour of the project structure and build targets.
There are several online sources for iOS app development tutorials using Java or Kotlin with Codename One.
Here are some useful links:
• Codename One Docs: The first steps, guides, tutorials and resources you need.
• Compare Codename One: Codename One’s comparison with other cross-platform frameworks.
• Codename One Maven Developer Guide
• Getting Started with the Bare-bones Java App Template
• Building a Codename One project for iOS (Video)
• Build Cross-Platform Native Mobile Apps Using Java/Kotlin for iOS, Android, Desktop and Web
Codename One is backed by a vibrant community of more than 100k developers in over 200 countries.
Codename One 1.0 was released in 2012 by ex-Sun engineers. It was the first solution to build native iOS apps in Java and it’s still the most mature, performant and stable cross-platform mobile toolkit for Java/Kotlin developers.
Quick Start with Codename One initializr
Build your first iOS app with Java/Kotlin now.
Frequently Asked Questions (FAQs)
Java code can't run on iPhone and iPad since there is no Java Virtual Machine (JVM) for iOS. However, Codename One can compile Java code to native iOS binary.
Yes, you can develop iOS apps without Swift using a compiler that can compile your code down to native iOS binary.
Yes, if you are a Java developer, you don’t need to learn Swift or Objective-C to develop iOS apps. You can use Codename One to develop iOS apps using Java or Kotlin.
Java is a good choice for iOS app development if you:
• Don’t know or want to learn Swift or Objective-C
• Want to build a cross-platform app
• Want easy deployment & maintenance
• Want to save costs & resources
Yes, you can build iOS apps without Xcode using Codename One, an open-source cross-platform framework for building native apps with Java/Kotlin.
Yes, you can build iOS apps on Windows using Codename One without using a Mac, macOS or Xcode.
Yes, it's legal to develop iOS apps on non-Apple hardware or software as it does not violate the Apple Developer Agreement.
You can build native iOS apps with Java using Codename One. Just sign up for a free Codename One account, go to Codename One initializr, and generate a starter project that you can open, run, debug, and build in your preferred IDE.
You can build native iOS apps with Kotlin using Codename One. Just sign up for a free Codename One account, go to Codename One initializr, and generate a starter project that you can open, run, debug, and build in your preferred IDE.
Building iOS apps with Swift is the obvious route if you want to develop specifically for iOS only.
But if you are a Java developer and don’t know Swift, Codename One is your best bet to develop iOS apps using Java or Kotlin.
Getting started with Codename One is easy. Just sign up for a free Codename One account, go to Codename One initializr, and generate a starter project that you can open, run, debug, and build in your preferred IDE.