Why is there no Java compiler on Android? I'm 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 realized 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?
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...