0

Im not an android developer but I do other stuff.

I just rooted my phone so I was playing around with a shell and I was trying to compile some c packages and realised there is no c compiler....OK

Surely there must be Java right? Tried it and I can't get a Java or javac command to work either. How is that possible when android apps are written in Java?

  • 2
    First, because Android devices are intended for end-users (sure also for developers, but they are in a minority ;) Second, your PC didn't ship with a compiler either, right? So third, you might have to install one. There are several IDEs available which run on Android – but this site here isn't for software recommendations :) – Izzy Nov 3 '16 at 21:46
  • I get that part....but how do the apps run with no Java? – deltaskelta Nov 3 '16 at 21:54
  • 1
    Running already compiled apps doesn't need a compiler being installed, right? We don't run them from source :) Depending on the Android version, there's some bytecode optimization done by either the Dalvik (< 5.0) or the ART (5.0+) engine, though, but that's something different. To give you a hint: To run a Java app on a PC, you need the JRE (Java Runtime Environment) – to compile a Java app from its source you need the JDK (Java Development Kit). Two different pairs of shoes, though the latter contains the former :) – Izzy Nov 3 '16 at 21:59
  • OK I guess I thought the java command i tried to run was part of the jre? No? – deltaskelta Nov 3 '16 at 22:03
  • You might wish to check our chat room – comments are not for discussion :) Short answer: for compiling, definitely no. And while Android apps are mostly written in Java, things are a bit different here. Goes to deep for this site, which is for end-users. – Izzy Nov 3 '16 at 22:06
1

If you have Android 5.0 (lollipop) or later, use termux. (Terminal IDE is great but only works up to android 4.*). It's on the google play store, and the source is on github.

It has an apt repository with several compilers, including ecj, the Eclipse Compiler for Java, and is much faster than javac.

There's also golang, clang, gcc, node, python and a whole bunch of other stuff (tmux, vim, ctags, cscope, emacs, latexetc etc etc).

NB: this doesn't actually answer your "why" question, but might be helpful...

0

Terminal IDE will do exactly what you want.

However, the app only works on Android 4.4 and below due to PIE restrictions.

On Android 5.0 and above, the binaries inside fail to run due to this error.

0

Try this app. Is called Java Manager. It can run .java , .class and .jar files. Java Manager

0

Yes you can install a Java compiler but don't expect to be able to create your own applications for Android on Android.

I asked a similar question here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.