I know some 'normal' Java (computer Java), and I want to run such a program on my Android device. Is this possible? If yes, how?
4 Answers
Generally, this is not possible as although Android-flavored Java has the same syntax and semantics as typical Java, it does not run on the same virtual machine (Google has its own VM that Android phones all ship with and which has a different byte code format than conventional Java VMs), nor does it use or have access to Oracle's Java standard library.
Google reimplemented most of the important elements (e.g. Google has its own implementation of HashMap
, ArrayList
, etc.) and ditched a lot of other stuff (e.g. there's no Swing package in Google's library).
If by 'normal' Java (computer Java) you mean Java Standard Edition (J2SE - the Java programs that usually run on a PC, like Eclipse, Vuze etc...) then the answer is most probably no. There is no way to run them directly on Android and there are no (at least not known to me) apps or modifications that allow it.
The apps (emulators) mentioned in other answers are for the J2ME (Java2 Micro Edition, also known as MIDP and applications as "midlets") environment. They are the Java applications for mobile devices that were popular before Android appeared.
You can do it quite easily as there are many ways to run Java apps on Android. Specific application called Java Emulators can do it quite easily.
These are the popular Java emulators for Android: viz, JBED, PhoneME, Jblend and NetMite. There are arranged in order of my preference. You can use PhoneME for unrooted devices; however, if your device is rooted try any of the remaining three applications.
You could try using JBED. JBED is a program designed to offer the possibility to use Java applications (.jar
files, I believe) on devices with the Android OS. I've never used it so can't personally vouch for it.
-
1According to the listing on the dodgy third-party site you linked to, it's only for J2ME mobile applets. The OP didn't say if that was what they wanted. Commented Feb 18, 2014 at 9:30
-
I know the site isn't great, there's XDA and DroidBeans links if OP wants to Google for it, but it does say it can run .jars which full JavaSE can be exported as. If I get a chance to test it I'll update.– PeanutCommented Feb 18, 2014 at 17:45
-
1Just for the sake of completeness, this website provides a how-to install and use the app. I tested on Lollipop but it didn't work though (the readme says about Gingerbread, so I'm not sure if it's compatible on the latest Android). (Disclaimer: I don't have any relation with the blog & its blogger. Just curious of this app from another question and found this article)– Andrew T. ♦Commented Feb 16, 2015 at 2:47