Overview of JDK Tools: javac, java, jar, and javadoc
You'll learn what the four essential command-line tools in your JDK do and when to use each one.
Now that you've installed the JDK and verified it works with java -version, it's time to understand the toolkit you've just unlocked. The JDK includes several command-line programs that work together to turn your code into running applications.
The Four Essential Tools
javac - The Compiler
Think of javac as a translator. You write Java code in .java files (human-readable text), and javac translates it into .class files (bytecode that the JVM understands). Without this step, your code is just text on a screen.
java - The Launcher
This is the command that actually runs your program. It starts the JVM and tells it to execute the bytecode in your .class files. You've already used this when you ran java -version—that's the same java command that will launch your applications.
jar - The Packager
As projects grow, you'll have many .class files. The jar tool bundles them together into a single archive file (like a zip file). This makes it easy to distribute your application or use libraries written by others. Think of it as packing a suitcase instead of carrying individual items.
javadoc - The Documentation Generator
Good developers document their code. javadoc reads special comments in your Java files and automatically generates professional HTML documentation, similar to the official Java documentation you might browse online.
The Workflow
In simple terms: you write code → javac compiles it → java runs it. Later, jar packages it and javadoc documents it.
Key Takeaway: The JDK provides four core tools—javac compiles your code, java runs it, jar packages it, and javadoc documents it—forming a complete development workflow.