javac[ options ] [ sourcefiles ] [ classes ] [ @argfiles ]
Arguments may be in any order.
One or more source files to be compiled (such as MyClass.java).
One or more classes to be processed for annotations (such as MyPackage.MyClass).
One or more files that lists options and source files. The-Joptions are not allowed in these files.
There are two ways to pass source code file names tojavac:For a small number of source files, simply list the file names on the command line. For a large number of source files, list the file names in a file, separated by blanks or line breaks. Then use the list file name on thejavaccommand line, preceded by an@character.
Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such asMyClass$MyInnerClass.class.
You should arrange source files in a directory tree that reflects their package tree.The source code forcom.mysoft.mypack.MyClassshould be inC:\workspace\com\mysoft\mypack\MyClass.java.
You can specify a separate destination directory with-d.
Set the destination directory for class files. The directory must already exist;javacwill not create it. If a class is part of a package,javacputs the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify-d C:\myclassesand the class is calledcom.mypackage.MyClass, then the class file is calledC:\myclasses\com\mypackage\MyClass.class.
If-dis not specified,javacputs each class files in the same directory as the source file from which it was generated.
Note:The directory specified by-dis not automatically added to your user class path.
Non-standard options begin with-X.
Specify where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in theCLASSPATHenvironment variable. If neitherCLASSPATH,-cpnor-classpathis specified, the user class path consists of the current directory.
If the-sourcepathoption is not specified, the user class path is also searched for source files.
If the-processorpathoption is not specified, the class path is also searched for annotation processors.
Setting the class path
The class path is the path that the Java runtime environment searches for classes and other resource files.
Class paths to the .jar, .zip or .class files. Eachclasspathshould end with a filename or directory depending on what you are setting the class path to:For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file. For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).
Multiple path entries are separated by semi-colons. With thesetcommand, it's important to omit spaces from around the equals sign (=).
The default class path is the current directory. Setting theCLASSPATHvariable or using the-classpathcommand-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.
Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.
Generate all debugging information, including local variables. By default, only line number and source file information is generated.
Do not generate any debugging information.
Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are:
Source file debugging information
Line number debugging information
Local variable debugging information
Passoptionto thejavalauncher called byjavac. For example,-J-Xms48msets the startup memory to 48 megabytes. It is a common convention for-Jto pass options to the underlying VM executing applications written in Java.
Note:CLASSPATH,-classpath,-bootclasspath, and-extdirsdonotspecify the classes used to runjavac. Fiddling with the implementation of the compiler in this way is usually pointless and always risky. If you do need to do this, use the-Joption to pass through options to the underlyingjavalauncher.
Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by semicolons (;) and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name.
Note:Classes found through the class path may be subject to automatic recompilation if their sources are also found.
Command-line options separated by spaces. SeeOptions.
The name of the class to be launched.
The name of the Java Archive (JAR) file to be called. Used only with the-jaroption.
The arguments passed to themain()method separated by spaces.