Java Reference
In-Depth Information
• jdeps
• jps
• jstat
• jstatd
• jinfo
• jstack
• jmap
• javap
javac
Basic usage
javac some/package/MyClass.java
Description
javac
is the Java source code compiler—it produces bytecode (in the form of
.class
files) from
.java
source files.
For modern Java projects,
javac
is not often used directly, as it is rather low-level
and unwieldy, especially for larger codebases. Instead, modern integrated develop‐
ment environments (IDEs) either drive
javac
automatically for the developer or
have built-in compilers for use while code is being written. For deployment, most
projects will make use of a separate build tool, such as Maven, Ant, or Gradle. Dis‐
cussion of these tools is outside the scope of this topic.
Nevertheless, it is useful for developers to understand how to use
javac
as there are
cases when compiling small codebases by hand is preferable to having to install and
manage a production-grade build tool such as Maven.
Common switches
-classpath
Supplies classes we need for compilation.
-d some/dir
Tells
javac
where to output class files.
@project.list
Load options and source files from the file
project.list
.
-help
Help on options.
-X
Help on nonstandard options.