The most important Java CLI tools to know |Video upload date:  · Duration: PT3M34S  · Language: EN

Compact guide to essential Java command line tools with examples and practical tips for java javac jshell jar jlink jmap jstack jstat jdeps javadoc

Practical Java CLI guide for debugging packaging and runtime performance

If you work with Java you will meet a handful of command line tools that do the heavy lifting while your IDE takes credit. This quick guide covers the tools that actually matter for running code building jars, generating docs and debugging memory and threads. Read this and you will stop blaming the build server for five minutes at least.

Runtime and compile basics

Start here when something is failing and you have no idea why. These are the first things to check before summoning the senior developer with a coffee mug that says I broke production.

java

Runs compiled classes on a chosen Java runtime. Always check the runtime version before blaming a dependency mismatch or the build pipeline.

java -version

javac

The compiler that turns .java into .class. If javac complains check your classpath and module path rather than yelling at your editor.

javac MyApp.java

jshell

A REPL for Java. Great for poking APIs or testing a one liner without creating an entire project and several existential questions.

jshell

Docs and packaging

Ship code that other humans can use and packages that actually run. These tools keep your releases from being a mystery wrapped in a zip file.

javadoc

Generate API docs from Java source comments. Good documentation saves teammates from guessing and future you from regret.

javadoc MyApp.java

jar

Bundle classes and resources into archives. If your runnable jar does not find the main class check the manifest and stop guessing.

jar cfm app.jar Manifest.txt -C classes .

jlink

Create a custom runtime image that contains only the modules you need. This is the practical way to avoid bloated containers and surprise storage bills.

jlink --module-path mods --add-modules my.app --output my-image

Diagnostics and performance

When the app behaves like it drank three espressos these tools help you find memory leaks deadlocks and GC drama without resorting to ritual sacrifice.

jmap

Inspect the heap for memory analysis. Useful when memory consumption looks like a toddler who found a candy jar.

jmap -heap <PID>

jstack

Dump thread stacks to diagnose deadlocks stalls and livelocks. Paste the output into an issue and watch the investigative work begin.

jstack <PID>

jstat

Monitor JVM stats over time to track garbage collector behavior. Live metrics beat guesswork and prayer for performance tuning.

jstat -gc <PID> 1000

jdeps

Analyze static dependencies to clean up accidental libraries and plan module migration. Great for projects that acquired dependencies like souvenir magnets.

jdeps -summary my.jar

Quick troubleshooting checklist

  • Include the java runtime version when filing issues
  • Share the classpath or module path used to run the app
  • Provide a minimal reproducer so someone else can actually run your problem

These three things save hours and prevent blame from being assigned to the nearest build tool. Use the right CLI tool for the task and you will look competent even on days when you are not.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.