The Codename One team, which makes a Java toolkit for building iOS and Android apps, writes about Java, mobile development and the mobile web.
HN commenters bring it up as a Java-based cross-platform mobile option, compared with Xamarin and RoboVM, and one questions its app gallery.
>> What is Java's equivalent of Xamarin or Avalonia?
Xamarin - RoboVM was a Java-based competitor to Xamarin which Xamarin acquired in 2015, but it was shutdown in 2017 after Microsoft acquired Xamarin. There are some Java-based toolkits such as https://www.codenameone.com/ that target mobile, but they are probably not as well funded as Xamarin has been under Microsoft. From what I hear Xamarin will be deprecated and replaced by MAUI.
Avalonia - Java has had multiplatform windowing for much longer than C# has. The Java Swing toolkit has been part of Java for more than a decade and is still supported in OpenJDK. JavaFX (https://openjfx.io/) is a newer toolkit that was originally part of Java and was later spun out into its own project.
How well are Xamarin and Avalonia supported if you are doing C# development on Mac or Linux?
>> How do I run Java on iOS?
As stated above, some tools such as https://www.codenameone.com/ and https://github.com/google/j2objc that convert Java code to target iOS.
I have never tried using those tools so I am not sure how good they are.
That is one way to define native. Another is to use the platform native source code and provide access to that. E.g. on Android Xamarin includes an overhead due to constantly passing thru the slow JNI bridge when it needs to communicate with the native UI widgets. It also includes a relatively large overhead because of standard C# libraries that need to be included on iOS/Android.
OTOH Codename One ( https://www.codenameone.com/ ) has a very different interpretation of "native". They use their own widget toolkit like QT which makes them "less native" in that regard. But they are native to Android (being Java based) and translate directly to C/Objective-C which means you can literally write OS native code and use native widgets within the hierarchy.
I think native is a worthless word in that regard as it doesn't properly convey meaning in these sort of complex situations. Once PhoneGap started billing itself as "native" this all went out of the window...
Naturally depends on the use case, yet they work good enough to be in business for 20 years.
https://www.ptc.com/en/products/developer-tools/perc
https://www.aicas.com/wp/products-services/jamaicavm-tools/
https://www.codenameone.com/
Android 5 & 6 (only changed back into JIT/AOT due to long compile times), https://www.infoq.com/news/2014/07/art-runtime/
Unfortunely the best well known, Excelsior JET, is no longer in business, most likely due to GraalVM and OpenJ9 being available as free beer, while PTC, Aicas Codename One are safe in their domains.
There is also RoboVM (https://github.com/MobiVM/robovm) as free beer, however it actually started as a commercial product, and the acquisition from Xamarin kind of stagnated it (naturally).
Besides RoboVM [1], there are also other solutions, like Codename One [2] that's based on XMLVM [3], or Avian [4] which is a new and very promising lightweight VM that can also compile code to native. And there's also J2ObcC [5] a compiler that's being developed and used by Google to share code between Android and iOS.
You know, Java can be many things, but you can't beat its ecosystem ;-)
[1] http://www.robovm.org/
[2] http://www.codenameone.com/
[3] http://xmlvm.org/overview/
[4] http://oss.readytalk.com/avian/
[5] http://code.google.com/p/j2objc/
I think Swing is a non-goal of this project. It provides good interop with the DOM and core JS methods, and it makes it easy to create your own interop for JS apis that aren't in the core.
There are at least two GUI toolkits that run on TeaVM: 1. Codename One. Similar to swing, but focused on mobile https://www.codenameone.com 2. SnapKit. Targeted at desktop. Also a light-weight toolkit, like Swing. https://github.com/reportmill/SnapKit
Their FAQ (http://www.codenameone.com/faq.html) claims that it is possible, though a little complicated (and they'll only provide support if you're on their enterprise plan).