Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross platform Java? Android and desktop

Tags:

java

android

We have a desktop/web java application and also getting into Android development.

Ideally we would like one app that runs both on desktop and android.

From what we can tell, it's not much possible to run normal java apps on android. But wondering if it can do it the other way? That is, run android apps easily on the desktop (without the user install the sdk or android emulator)?

In a prefect world we'd like one app for both platforms. Realistically though it seems like we're going to have to have one app with two front ends?

like image 737
dime Avatar asked Oct 08 '10 20:10

dime


2 Answers

Basically you would break your application into at least three projects... one Android project for the Android-specific stuff, one desktop Java project for the desktop-specific stuff and then one Java library project for the common functionality (where most of your real work should be done). Then you can reuse the library project in both the Android and desktop projects.

There are some differences in what is available in the Android environment so you will need to keep an eye on that, but with some good design you should have no problems sharing quite a bit of code between your projects.

Good luck.

like image 101
cjstehno Avatar answered Oct 29 '22 13:10

cjstehno


Check out libgdx, it may be just what you are looking for. http://code.google.com/p/libgdx/

like image 27
Kenji Avatar answered Oct 29 '22 13:10

Kenji