JRE & JDK: Java Development Kit (JDK)

Components of the Java Development Kit

Overview

Typically, when we talk about the Java Development Kit (JDK), we’re referring to the tools that are part of the JDK but not part of the JRE subset of the JDK—in other words, those that we use to develop Java applications and libraries.

Development tools

javac: Compiler

This program is used to compile the code in Java source files (with a .java extension) to bytecode, writing the output to Java bytecode files (with a .class extension).

Syntax

javac [options] [source files]

options (subset)

-help, -?

Displays information on all available standard options.

-version

Displays version information.

--class-path <path>, -classpath <path>, -cp <path>

Specifies the classpath—one or more directories, separated by semicolons on Windows and colons on OS X and Linux, in which the compiler will search for classes referenced by the code being compiled.

-d <directory>

Specifies the base directory into which the output bytecode files will be generated.

Simplified operation diagram

Java compiler (`javac`) diagram

javadoc: Documentation generator

This tool generates technical documentation from the Java source code, including Javadoc comments embedded in the source code. The standard JDK includes a doclet that generates this documentation in HTML format; 3rd-party doclets can be used to generate output in PDF, CHM, $\rm\LaTeX$, DocBook, and other formats.

Syntax

javadoc [options] [packagenames] [sourcefiles] [@files]

options (subset)

-help, -h, -?

Displays information on general options, and options for the standard doclet.

-version

Displays version information.

-subpackages <package [package [...]]>

Specifies the source code subpackages to load. (These will be loaded recursively.)

-show-members <accessLevel>

Specifies the minimum access level for inclusion in the documentation; default is protected.

-d <directory>

Specifies the directory into which the generated HTML files will be written.

-link <url>

Links will automatically be created for explicit and implicit references to types documented at url.

-windowtitle <title>

title will be used to generate the text in the <title> element of the generated HTML.

jshell: Read-Evaluate-Print Loop (REPL)

jshell is a Java-specific shell, providing an interactive, command-line-based environment for writing and executing Java code. While not an IDE, it is well-suited to executing simple statements, compound statements, and even simple classes.

Syntax

jshell [options] [load-file]

options (subset)

--help, -h, -?

Displays information on available options.

--version

Displays version information.

--class-path <path>, -c <path>

Specifies the classpath—one or more directories, separated by semicolons on Windows and colons on OS X and Linux, in which the compiler will search for classes referenced by the code compiled and executed in the shell.