开发者

Can I run a "standard", non-Android, Java app on Android?

开发者 https://www.devze.com 2023-01-09 13:40 出处:网络
In my case I want to write an app which is totally symetrical (not client-server) with identical functionality at two PCs, one a \'standard\' Windows or Linux box and the other an Android slate.

In my case I want to write an app which is totally symetrical (not client-server) with identical functionality at two PCs, one a 'standard' Windows or Linux box and the other an Android slate.

Can I run the same program on both or do I n开发者_如何学Goneed to wrap it in an Android package for persmissioons, etc?

The two PCs will communciate by TCP/IP, sort of peer-to-peer, but I suspect that as a generic question this might be of interest to many.


Well you cannot run an independent java application on Android. Android applications are compiled to dalvik bytecode and really are just written in java but not run on the java vm (Android does not have a java vm). However you can create a jar library that can be consumed by both a desktop and android application and that should provide reuse of platform independent code.


You can run command-line Java programs on an Android device. An example of a simple "hello, world" program is described here.

As noted previously, though, you can't use the Android framework for UI, and unless you have a rooted phone you won't be able to install it in /data or access "protected" features like talking to the Internet.

0

精彩评论

暂无评论...
验证码 换一张
取 消