简体   繁体   English

如何在Android上运行普通的旧Java应用程序

[英]How to run plain old java application on Android

I want to run a Java application on Android. 我想在Android上运行Java应用程序。 It does not have a user interface and embeds Jetty as a servlet containr. 它没有用户界面,并且将Jetty嵌入为servlet容器。 It implements a web application that is normally accessed online by its users but I need to run this offline on Android tablets. 它实现了通常由其用户在线访问的Web应用程序,但是我需要在Android平板电脑上离线运行此应用程序。

Is this at all possible? 这是可能吗? All I have been able to find is information on how to develop Android apps. 我所能找到的只是有关如何开发Android应用程序的信息。 I simply want the equivalent of java -jar ... and any information would be welcome. 我只想要java -jar ...的等效物,任何信息都将受到欢迎。

There is no equivalent of this in Android. Android中没有与此等效的功能。 Android uses a DVM instead of a normal JVM, which is based on Apache Harmony . Android使用DVM代替基于Apache Harmony的普通JVM。

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. 无论如何,您都需要重新编译应用程序,因为DVM仅执行Dalvik-Bytecode,该Dalvik-Bytecode是由Android SDK附带的dx -tool从常规Java字节码创建的。

Also, why do you need to run a Server-Application on a tablet device? 另外,为什么需要在平板设备上运行服务器应用程序?

You can't normally just run Java code, Android devices don't even have a Java VM. 通常,您不能只运行Java代码,Android设备甚至都没有Java VM。 You have to recompile your application and convert it to dex, which is used by Dalvik VM. 您必须重新编译您的应用程序并将其转换为Dalvik VM使用的dex。 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. 这样做是否容易,当然取决于您使用的API,因为Android仅具有Java SE API的子集。

try GNURoot app (proot ptrace container) with debian Wheezy; 尝试使用带有debian Wheezy的GNURoot应用程序(proot ptrace容器);
apt-get update apt-get更新
apt-get install openjdk-7-jre apt-get install openjdk-7-jre
/usr/lib/jvm/java-7-openjdk-armel/jre/bin/java ... / usr / lib / jvm / java-7-openjdk-armel / jre / bin / java ...
(including long path) (包括长途旅行)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM