Can Computer-Grade Java run on Android Phones?

0

Not sure if I can ask this here or on Stack Overflow...

Can normal Java (Computer-Grade Java) run on Android Phones? Or are the two completely different versions of Java?

By Computer-Grade Java, I mean like projects from Eclipse and Netbeans (with the project folders and the build files)

GipsyD

Posted 2016-11-11T16:24:03.543

Reputation: 155

Question was closed 2016-11-15T00:11:53.450

1StackOverflow is better. I have flagged this to be moved to StackOverflow.. – Tonny – 2016-11-11T16:38:07.930

1eh. No. And not really that much on topic here, though I'll let the community decide on that. – Journeyman Geek – 2016-11-12T00:47:10.783

Answers

2

Typical phones that run operating systems such as Android user their own JVM (Java Virtual Machine). The JVM is responsible for handling what is known as "bytecode." You can think of the JVM kinda like a virtual processor that is able to process bytecode. It is more complex than this, but I won't go into too much detail on that.

So essentially you have multiple JVMs for different CPU architectures (such as ARM for phones and x86 for desktop machines). These JVMs can process bytecode and provide a consistent experience across devices in this way. However, if the libraries your application rest upon require native system specific APIs, it will not work. So if you code a regular old Java app using Swing or SWT, it will not work on Android as Android does not provide those APIs (to my knowledge) to leverage. Furthermore Android has a very specific setup for how their applications work and Android provides its own implementation of the JVM. It is very different from Oracles.

So if you're just coding something in Java like a command line application or simple UI application, you are not going to get that to work on Android as you would on your PC.

James Manes

Posted 2016-11-11T16:24:03.543

Reputation: 230

Woah. Very nice answer. – GipsyD – 2016-11-11T16:44:23.747