I have coded a simple video game in Java. It works fine on all computers that have Java installed. However, I would really like to play it on my smartphone and it would also be nice to be able to play it on pretty much any smartphone no matter what model/company/OpSys etc. Here is my question:

How can I convert my Java video game into something that runs on mobile devices (a smartphone), ideally without completely rewriting the whole source code?

After all, the idea of Java is that you write the code once and then it runs on pretty much all devices. I would not mind copy-pasting my own source code and maybe add/change a few lines of code. But I would really like to avoid having to rewrite it in some completely different language.

Details about my game: It is a simple one-player vs CPU 2D card game, where you click on a few buttons and pictures. Every now and then there is a dialog window. That's pretty much all. But there are many pages of AI / game logic source code.

On the computers the input for this game is just left-clicking on the buttons. Ideally, on a device with a touch screen, one would just touch the buttons depicted on the screen. I have not really looked into porting myself that much. My hope was that in this modern day and age, where smartphones are pretty much computers, there would be something as close to a one-click-converter as possible. Again, the original idea was that with Java you are supposed to write one source code for all devices.

  • 1
    \$\begingroup\$ I'm not super familliar with Java or porting to mobile, but I think it would be helpful if you mentioned what you use for input, rendering, audio etc. as that will most likely affect the difficulty of doing this. \$\endgroup\$
    – user35344
    Jun 4, 2021 at 11:32
  • 1
    \$\begingroup\$ Porting can often be a big job, even in languages and frameworks that go a long way to ease cross-platform development. We can't fit a complete guide to every porting issue you might encounter in a single answer here (and existing resources on the web probably cover these in greater detail anyway). What we can do is help you with a specific problem you've encountered in your porting attempts so far. For instance, you've probably already looked up some tutorials about how to develop a Java game for Android? Where did you encounter trouble applying what you learned to your Java game? \$\endgroup\$
    – DMGregory
    Jun 4, 2021 at 11:36
  • \$\begingroup\$ "I have not really looked into porting myself that much" - then it sounds like you're a bit early in your journey yet to make the best use of this site. Asking on StackExchange should not be step one. You should start by searching out existing resources and guides about your topic, and making your best effort to use them to solve your problem. Often, that's all you need, and you'll succeed without having to wait for new answers. But if not - if you run into a roadblock - that's when it's time to come here and ask folks to volunteer to write something new for you. \$\endgroup\$
    – DMGregory
    Jun 4, 2021 at 12:00
  • \$\begingroup\$ For many years Java was the default way to create mobile apps, and while smart phones have made it less ubiquitous, many still run java apps. That said, it's not a standard runtime, it comes with limitations and completely different I/O and rendering concepts, not to mention a whole slew of additional considerations (saving state during screen off/hibernation, power conservation, etc). There's no simple quick A to B converter, people build whole careers on frameworks designed to bridge the gap, and they usually require you to use them from day one and code with their quirks in mind. \$\endgroup\$
    – Basic
    Nov 2, 2021 at 0:05

2 Answers 2


What you want to do is most likely not as easy as you think. Yes, Java is one of the main programming languages for Android, but that's where all the similarities end with desktop and browser-based Java.

It really depends on the environment you're using. Unless you're using something game-oriented, such as libGDX, or a natively multiplatform framework, like Codename One, the entire programming paradigm from desktop and browser simply doesn't apply to Android. Even the concept of a program that starts with public static void main(String[] args) doesn't really apply to Android -- Android Java programming works in terms of activities and intents, not processes and command line parameters.

Certainly the purely algorithmic parts of your game, which don't depend on any external library, could in principle be used as-is, or almost-as-is, but all the platform interaction, from graphics, to sound, to input, is dramatically different.

Cross platformness is a state of mind, not a programming language. In fact, it is probably easier to port a C/C++ game that uses OpenGL from desktop to Android, than porting a native Java app/applet to Android.


It seems possible, albeit not being trivial:


“[...] brings Java and JavaFX to mobile […] including iPhone, iPad, Android devices, and the Raspberry Pi.“

“Write once, run anywhere.“ I love that slogan!

It seems one 'just' has to install some development environments (and maybe some plug-ins), add a few lines of code, test and compile and most of the porting is done automatically.

I will try it. But I will need quite a while to get through this all. Good thing the website has a documentation that guides one through the whole process. Also there seems to be a community/forum about it right here: http://stackoverflow.com/questions/tagged/javafxports

In hindsight, I should have posted the question on Stack Overflow right from the beginning. But I guess, it cannot hurt being here.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .