Compile, Run, Package, and Inspect

A minimal workflow is: write source, compile it, run it, package it when needed, and inspect artifacts or diagnostics when something fails.

javac Application.java
java Application
jar --create --file app.jar --main-class Application Application.class
java -jar app.jar

For real projects, Maven or Gradle normally handles dependency resolution, compilation, testing, packaging, code quality, and publishing. The command-line tools remain important because they reveal what the build tool is doing underneath.

Compilation errors are caught before execution. Runtime failures such as NullPointerException, ClassNotFoundException, or an out-of-memory condition happen after compilation and require different debugging techniques.

Build-tool principle

Learn the JDK commands even if you use Maven or Gradle; they make build failures easier to reason about.

Key Takeaways
  • javac compiles source; java launches a class; jar packages artifacts.
  • Build tools automate repetitive workflows but do not replace understanding the JDK tools.
  • Compilation success does not guarantee runtime correctness.