Your Java 8 install is only for the Java Runtime Environment (JRE). Therefore, it won't have a Java compiler (javac). The compiler is part of the Java Development Kit (JDK).
Try installing Java 8 JDK: sudo apt-get install openjdk-8-jdk. It is likely that your Java 11 distribution is also a JRE-only install. If you need it, just install it the same way as I showed you for Java 8.