tags:

views:

115

answers:

4

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?

A: 

Where did you heard about that?

Android's primary development language is Java, even though they used Dalvik VM instead of Java VM. You'll need to recompile your .java code, and there are some parts of Java libraries that are not available in Android and vice versa, and you'll obviously need to write a separate GUI frontend; but that's it, you can have largely the same codebase to run in both platforms.

Lie Ryan
+4  A: 

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.

cjstehno
A: 

You are correct in that you won't be able to take your standard class files and have them just run on android. The byte code produced by the dalvik vm is distinct from the byte code produced from a jvm. However much of your code will be reusable and with good design you could lessen this problem considerably.

Kevin D
A: 

It is not a good idea to use the same GUI on a smart phone and on a desktop system. You need to use completely other using concepts. For your business logic a splitting in 3 project like cjstehno can be a good idea.

Horcrux7