Using libGDX with other JVM languages

libGDX is mainly a Java-based framework. However, because Java produces Java bytecodes, and the virtual machine runs these bytecodes, it is possible to run libGDX in any JVM language with proper Java interoperability.

Some target platforms can’t run Java bytecodes directly, and so have more specific compilation requirements. Using a language other than Java may affect support for these platforms.

Language interoperability guides

Target platform compatibility

Desktop

This works out of the box, as the desktop libGDX back-end uses the JVM that you have installed on your computer, which is most likely either OpenJDK or Oracle JDK. Both of these JVMs support polyglot code, as they run on .class files, not Java source code.

Android

This works for many languages, but it is sometimes unavailable. For best results, search on your favorite search engine “[JVM language of choice] on Android”.

Some examples:

iOS-ROBOVM

The ROBOVM backend is a JVM on iOS which executes Java bytecode. This should work, but has not been tested!

HTML/GWT

Because libGDX uses GWT, JVM languages other than Java cannot use the HTML5 target of libGDX. GWT transpiles Java to JavaScript, as opposed to Java bytecode (.class files) to JavaScript code. There are a few reasons for this, quickly outlined by a Google employee here.

This could theoretically be fixed for JVM languages that have their own JavaScript back-ends, such as Scala and Kotlin. Your libGDX project’s build system would have to be changed to integrate with those back-ends instead of with GWT.

Examples

Many people have used libGDX in their JVM language of choice. Here are some examples.

TODO (find some recent examples, would love contributions!)

Reference

https://web.archive.org/web/20201031162718/https://www.badlogicgames.com/wordpress/?p=2750