Compile a .java file and place the resulting class file in a specific directory

javac

  • Java application compiler.
    More information: <https://docs.oracle.com/en/java/javase/19/docs/specs/man/javac.html>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

javac -d {{path/to/directory}} {{file.java}}

click the source code to copy install javac on any operating system with command-not-found.com