Compiling Java on the command line

Alonso Del Arte
5 min readJul 3, 2024
Photo by Greg Rosenke on Unsplash

Aside from maybe Hello World, most of you have probably never compiled a Java program on the command line. And why would you? An integrated development environment (IDE) makes it very easy to edit, compile and run a project consisting of dozens of classes in a dozen packages.

Programmers in the early days of Java didn’t have IDEs. They didn’t even have build tools. The programs had to be compiled on the command line, which is just fine for Hello World but somewhat daunting for any project more involved than that.

Then build tools came along. Most of the build tools added their own complexity to a project, and that is still true of the build tools available today. But at least the build tools have been absorbed into the IDEs and most Java programmers are spared the annoyance of having to deal with build tools directly.

For me, studying how to compile Java projects on the command line is worthwhile because I’m working on a build tool that uses markdown instead of XML to guide the build process. For you it might be worthwhile for no other reason than to give you a renewed appreciation for your IDE.

To compile Java source from the command line and run the resulting programs, it’s nice to have the path variable set to the Java Runtime Environment (JRE) and Java Development Kit (JDK), giving us two fewer paths to…

--

--

Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified