Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run plain old java application on Android

Tags:

java

android

I want to run a Java application on Android. It does not have a user interface and embeds Jetty as a servlet containr. It implements a web application that is normally accessed online by its users but I need to run this offline on Android tablets.

Is this at all possible? All I have been able to find is information on how to develop Android apps. I simply want the equivalent of java -jar ... and any information would be welcome.

like image 867
Silvio Bierman Avatar asked Oct 19 '11 10:10

Silvio Bierman


2 Answers

There is no equivalent of this in Android. Android uses a DVM instead of a normal JVM, which is based on Apache Harmony.

You would in any case need to recompile the application since the DVM only executes Dalvik-Bytecode which is created from normal Java-Bytecode by the dx-tool shipped with the Android SDK.

Also, why do you need to run a Server-Application on a tablet device?

like image 144
Lukas Knuth Avatar answered Oct 12 '22 05:10

Lukas Knuth


You can't normally just run Java code, Android devices don't even have a Java VM. You have to recompile your application and convert it to dex, which is used by Dalvik VM. Whether it is easy to do so or not, depends, of course, on the APIs you use, since Android only has a subset of Java SE APIs.

like image 2
Malcolm Avatar answered Oct 12 '22 03:10

Malcolm