I'm a web developer and am thinking of digging into mobile app development. The languages I know so far are PHP, Python, SQL, Js, HTML and CSS, all of them pretty well now. Currently I'm starting to dig into Java, as it's the language to be used for native Android App Development, as far as I've learned. Interestingly, I'm coming across posts (also in this forum) saying that Java can also be used to develop iOS - compatible Apps, while other sources comment that Apple is completely against cross-devs, and that you should develop iOS apps using Swift when it comes to the native choice and optimal UX. So I was wondering about the answer in this forum; can you develop iOS apps using Java or not?
5 Answers
Post is a few months old now, but I figure someone with a similar question will probably find this with web search, so this reply is for them. For context, I wrote Java professionally for about five years, and I learned to program back when Java was supposed to be the future.
If the question is, "Can you write Java code and run it on iOS?" then the answer is, "Technically yes." But I would be cautious about whether that's something I actually want to do.
It requires a certain amount of sleight-of-hand under the hood to make it work. The tool linked in a previous answer, Codename One, strikes me as a fairly heavyweight framework. I would consider using it if my project was already commited to a Java codebase, but my instinct would be to avoid depending on it for a new project.
There are advantages to knowing Java in 2023, but in my view cross-platform mobile development isn't the most compelling use case.
Some reasons why you might want to learn Java in the current era include:
- Developing on Android. While Android now recommends Kotlin as the language of choice for new projects, Java was the sole first-class language on the platform for 10+ years, so it's advantageous to be able to read, write, and reuse Java code and libraries.
- Gaining insight into other JVM languages such as Kotlin and Scala. In my brief experience with Kotlin, I've found it to be a more elegant language than Java, but without prior knowledge of the JVM model and its limitations, it's difficult to appreciate Kotlin's design decisions or how it works "under the hood".
- Using long-standing big-data tools, such as Spark, Hadoop or Neo4j. While this domain has increasingly moved to Python since the mid 2010's, there's still a lot of production Java code that someone needs to maintain.
- Stylistic similarity to C-family languages. Java can be a more intuitive introduction to C-style languages than jumping right into C++. These days, though, I would consider learning C# over Java if this is your goal.
- Continuity with some Javascript dialects. In particular, React code embodies Object Oriented design conventions that are influenced by Java practices, and those design choices in turn have influenced changes in the JS spec. Being familiar with Java conventions can help make sense of those design patterns. It can also help you identify which of those Object Oriented practices are bad ideas, so you can avoid them in Javascript applications.
In my view, there are a lot of good reasons people have moved away from Java since 2006 or so:
- It's notorously verbose, and requires a lot of esoteric knowledge about implementation details to write code that runs efficiently. This is the problem that languages like Scala and Kotlin have tried to solve in their respective domains, while retaining compatibility with the JVM platform for ease of migration.
- The JVM platform has traditionally introduced substantial overhead in resource usage and integration complexity. As time has gone on, JVM's have become more efficient and tools have developed to compile Java directly to native code, but in my view the integration complexity remains a substantial bottleneck. Particularly on Android, there's often a need to call native functions from JVM code, and this remains a pain point.
- Changes in approach and policy since Sun's acquisition by Oracle. This is related to licensing issues (see Oracle v Google), as well as feature creep, which has given rise to compatibility issues across codebases. It's also led to a fracturing of the ecosystem between proprietary and open-source JVM implementations, which can impact performance.
- Emergence of viable alternative languages in the 2000's and 2010's.
- New technologies have emerged to solve the compatibility issues that Java was designed to address. A key "selling point" of Java and the JVM model was the ability to run the same code on a variety of platforms. But today, that goal is more commonly achieved by running code in virtual machines, in Docker containers for backend systems, or via Web Assembly in-browser.
It's ironic, since the motto of Java used to be "write once, run everywhere", but that's the way things go.
(Edit, June 2023: Thank you to the commenters below for pointing out some shortcomings in this answer and clearing up some of my misconceptions. I've updated the text to reflect some of this feedback, such as removing extraneous asides, and also to make the overall tone more approachable.)

- 130
- 1
- 3
-
1“The JVM platform itself introduces substantial overhead, both in resource usage and integration complexity.” That hasn’t been true since the 20th century. – VGR Aug 31 '22 at 14:58
-
-
2This is a very uninformed answer, by someone who is obviously not a Java developer. You clearly do not understand the modern Java platform, or its reach. Additionally, Codename One compiles Java down to native iOS machine code, just like Swift, so most of your arguments go completely out the window. Modern Java versions include the same features as Scala and Swift. The latter is far more cumbersome to write than Java, and certainly won't help you write cross-platform apps. – Dave Jan 28 '23 at 11:32
-
This answer has some good and bad parts. But I doubt if this answer is the most useful for the asker to be accepted. Good point about Apache in the light of the origin of its name, yet politics aside I want to contribute with some factual correction. Apache HTTP server is written in C language. It is maintained by Apache Foundation, which also supports many open-source Java projects, but the HTTP server is not Java. Yet I wonder if the creators of Java language are actually Javanese. – Luke 10X May 25 '23 at 11:45
Yes you can.
One tool used for this is Codename One. https://www.codenameone.com/
Also for more info on this subject, feel free to consult this thread: How can one develop iPhone apps in Java?

- 2,078
- 3
- 19
- 29
Yes, this is possible. https://github.com/Anuken/Mindustry is an open-source RTS game written in Java. It has an iOS port that is compiled via an open-source fork of RoboVM.

- 140
- 3
- 8
IOS works on objective C and Android works in Java and Kotlin. I don't know how much some conversion tool can help you to achieve all the functionality. So in my opinion answer is No. Hybrid Application development can help you. You have one source code that will run in both platform. You have to develop the app again.

- 208
- 1
- 10
First: Java is used in more Domains than C#. Needed information because C# has no way to get over with ONE UI to Desktop, Mobile and Web.
By the way, the recommended Solution is CodenameOne or - if you want to implement your App with JavaFX - use Gluonmobile which is using the GraalVM, an ahead of time compiler for IOS.
In both Cases you have access to Hardware of the Device for Android and IOS because there is an abstraction which helps you with implementations for both Platforms - Android And IOS. Write in this Case one App and compile for both worlds.

- 11
- 2