{
    "mode": "man",
    "parameter": "javac",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/javac/1/json",
    "generated": "2026-06-15T13:13:36Z",
    "synopsis": "javac [ options ] [ sourcefiles ] [ classes] [ @argfiles ]\nArguments can be in any order:\noptions\nCommand-line options. See Options.\nsourcefiles\nOne or more source files to be compiled (such as MyClass.java).\nclasses\nOne or more classes to be processed for annotations (such as MyPackage.MyClass).\n@argfiles\nOne or more files that list options and source files. The -J options are not allowed\nin these files. See Command-Line Argument Files.",
    "sections": {
        "NAME": {
            "content": "javac - Reads Java class and interface definitions and compiles them into bytecode and class\nfiles.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "javac [ options ] [ sourcefiles ] [ classes] [ @argfiles ]\n\nArguments can be in any order:\n\noptions\nCommand-line options. See Options.\n\nsourcefiles\nOne or more source files to be compiled (such as MyClass.java).\n\nclasses\nOne or more classes to be processed for annotations (such as MyPackage.MyClass).\n\n@argfiles\nOne or more files that list options and source files. The -J options are not allowed\nin these files. See Command-Line Argument Files.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The javac command reads class and interface definitions, written in the Java programming\nlanguage, and compiles them into bytecode class files. The javac command can also process\nannotations in Java source files and classes.\n\nThere are two ways to pass source code file names to javac.\n\n• For a small number of source files, list the file names on the command line.\n\n• For a large number of source files, list the file names in a file that is separated by\nblanks or line breaks. Use the list file name preceded by an at sign (@) with the javac\ncommand.\n\nSource code file names must have .java suffixes, class file names must have .class suffixes,\nand both source and class files must have root names that identify the class. For example, a\nclass called MyClass would be written in a source file called MyClass.java and compiled into\na bytecode class file called MyClass.class.\n\nInner class definitions produce additional class files. These class files have names that\ncombine the inner and outer class names, such as MyClass$MyInnerClass.class.\n\nArrange source files in a directory tree that reflects their package tree. For example, if\nall of your source files are in /workspace, then put the source code for\ncom.mysoft.mypack.MyClass in /workspace/com/mysoft/mypack/MyClass.java.\n\nBy default, the compiler puts each class file in the same directory as its source file. You\ncan specify a separate destination directory with the -d option.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "The compiler has a set of standard options that are supported on the current development\nenvironment. An additional set of nonstandard options are specific to the current virtual\nmachine and compiler implementations and are subject to change in the future. Nonstandard\noptions begin with the -X option.\n\n• See also Cross-Compilation Options\n\n• See also Nonstandard Options\n\nSTANDARD OPTIONS",
            "subsections": [
                {
                    "name": "-A_key_[_=value_]",
                    "content": "Specifies options to pass to annotation processors. These options are not interpreted\nby javac directly, but are made available for use by individual processors. The key\nvalue should be one or more identifiers separated by a dot (.).\n\n-cp path or -classpath path\nSpecifies where to find user class files, and (optionally) annotation processors and\nsource files. This class path overrides the user class path in the CLASSPATH\nenvironment variable. If neither CLASSPATH, -cp nor -classpath is specified, then the\nuser class path is the current directory. See Setting the Class Path.\n\nIf the -sourcepath option is not specified, then the user class path is also searched\nfor source files.\n\nIf the -processorpath option is not specified, then the class path is also searched\nfor annotation processors.\n\n-Djava.ext.dirs=directories\nOverrides the location of installed extensions.\n\n-Djava.endorsed.dirs=directories\nOverrides the location of the endorsed standards path.\n\n-d directory\nSets the destination directory for class files. The directory must already exist\nbecause javac does not create it. If a class is part of a package, then javac puts the\nclass file in a subdirectory that reflects the package name and creates directories as\nneeded.\n\nIf you specify -d/home/myclasses and the class is called com.mypackage.MyClass, then\nthe class file is /home/myclasses/com/mypackage/MyClass.class.\n\nIf the -d option is not specified, then javac puts each class file in the same\ndirectory as the source file from which it was generated.\n\nNote: The directory specified by the -d option is not automatically added to your user\nclass path.\n"
                },
                {
                    "name": "-deprecation",
                    "content": "Shows a description of each use or override of a deprecated member or class. Without\nthe -deprecation option, javac shows a summary of the source files that use or\noverride deprecated members or classes. The -deprecation option is shorthand for\n-Xlint:deprecation.\n\n-encoding encoding\nSets the source file encoding name, such as EUC-JP and UTF-8. If the -encoding option\nis not specified, then the platform default converter is used.\n\n-endorseddirs directories\nOverrides the location of the endorsed standards path.\n\n-extdirs directories\nOverrides the location of the ext directory. The directories variable is a colon-\nseparated list of directories. Each JAR file in the specified directories is searched\nfor class files. All JAR files found become part of the class path.\n\nIf you are cross-compiling (compiling classes against bootstrap and extension classes\nof a different Java platform implementation), then this option specifies the\ndirectories that contain the extension classes. See Cross-Compilation Options for more\ninformation.\n"
                },
                {
                    "name": "-g",
                    "content": "Generates all debugging information, including local variables. By default, only line\nnumber and source file information is generated.\n\n-g:none\nDoes not generate any debugging information.\n\n-g:[keyword list]\nGenerates only some kinds of debugging information, specified by a comma separated\nlist of keywords. Valid keywords are:\n\nsource Source file debugging information.\n\nlines  Line number debugging information.\n\nvars   Local variable debugging information.\n\n",
                    "flag": "-g"
                },
                {
                    "name": "-help",
                    "content": "Prints a synopsis of standard options.\n\n-implicit:[class, none]\nControls the generation of class files for implicitly loaded source files. To\nautomatically generate class files, use -implicit:class. To suppress class file\ngeneration, use -implicit:none. If this option is not specified, then the default is\nto automatically generate class files. In this case, the compiler issues a warning if\nany such class files are generated when also doing annotation processing. The warning\nis not issued when the -implicit option is set explicitly. See Searching for Types.\n"
                },
                {
                    "name": "-J_option_",
                    "content": "Passes option to the Java Virtual Machine (JVM), where option is one of the options\ndescribed on the reference page for the Java launcher. For example, -J-Xms48m sets the\nstartup memory to 48 MB. See java(1).\n\nNote: The CLASSPATH, -classpath, -bootclasspath, and -extdirs options do not specify\nthe classes used to run javac. Trying to customize the compiler implementation with\nthese options and variables is risky and often does not accomplish what you want. If\nyou must customize the complier implementation, then use the -J option to pass options\nthrough to the underlying Java launcher.\n"
                },
                {
                    "name": "-nowarn",
                    "content": "Disables warning messages. This option operates the same as the -Xlint:none option.\n"
                },
                {
                    "name": "-parameters",
                    "content": "Stores formal parameter names of constructors and methods in the generated class file\nso that the method java.lang.reflect.Executable.getParameters from the Reflection API\ncan retrieve them.\n\n-proc: [none, only]\nControls whether annotation processing and compilation are done. -proc:none means that\ncompilation takes place without annotation processing. -proc:only means that only\nannotation processing is done, without any subsequent compilation.\n\n-processor class1 [,class2,class3...]\nNames of the annotation processors to run. This bypasses the default discovery\nprocess.\n\n-processorpath path\nSpecifies where to find annotation processors. If this option is not used, then the\nclass path is searched for processors.\n\n-s dir\nSpecifies the directory where to place the generated source files. The directory must\nalready exist because javac does not create it. If a class is part of a package, then\nthe compiler puts the source file in a subdirectory that reflects the package name and\ncreates directories as needed.\n\nIf you specify -s /home/mysrc and the class is called com.mypackage.MyClass, then the\nsource file is put in /home/mysrc/com/mypackage/MyClass.java.\n\n-source release\nSpecifies the version of source code accepted. The following values for release are\nallowed:\n\n1.3    The compiler does not support assertions, generics, or other language features\nintroduced after Java SE 1.3.\n\n1.4    The compiler accepts code containing assertions, which were introduced in Java\nSE 1.4.\n\n1.5    The compiler accepts code containing generics and other language features\nintroduced in Java SE 5.\n\n5      Synonym for 1.5.\n\n1.6    No language changes were introduced in Java SE 6. However, encoding errors in\nsource files are now reported as errors instead of warnings as in earlier\nreleases of Java Platform, Standard Edition.\n\n6      Synonym for 1.6.\n\n1.7    The compiler accepts code with features introduced in Java SE 7.\n\n7      Synonym for 1.7.\n\n1.8    This is the default value. The compiler accepts code with features introduced\nin Java SE 8.\n\n8      Synonym for 1.8.\n\n\n-sourcepath sourcepath\nSpecifies the source code path to search for class or interface definitions. As with\nthe user class path, source path entries are separated by colons (:) on Oracle Solaris\nand semicolons on Windows and can be directories, JAR archives, or ZIP archives. If\npackages are used, then the local path name within the directory or archive must\nreflect the package name.\n\nNote: Classes found through the class path might be recompiled when their source files\nare also found. See Searching for Types.\n"
                },
                {
                    "name": "-verbose",
                    "content": "Uses verbose output, which includes information about each class loaded and each\nsource file compiled.\n"
                },
                {
                    "name": "-version",
                    "content": "Prints release information.\n"
                },
                {
                    "name": "-werror",
                    "content": "Terminates compilation when warnings occur.\n"
                },
                {
                    "name": "-X",
                    "content": "Displays information about nonstandard options and exits.\n\nCROSS-COMPILATION OPTIONS\nBy default, classes are compiled against the bootstrap and extension classes of the platform\nthat javac shipped with. But javac also supports cross-compiling, where classes are compiled\nagainst a bootstrap and extension classes of a different Java platform implementation. It is\nimportant to use the -bootclasspath and -extdirs options when cross-compiling.\n\n-target version\nGenerates class files that target a specified release of the virtual machine. Class\nfiles will run on the specified target and on later releases, but not on earlier\nreleases of the JVM. Valid targets are 1.1, 1.2, 1.3, 1.4, 1.5 (also 5), 1.6 (also 6),\n1.7 (also 7), and 1.8 (also 8).\n\nThe default for the -target option depends on the value of the -source option:\n\n• If the -source option is not specified, then the value of the -target option is 1.8\n\n• If the -source option is 1.2, then the value of the -target option is 1.4\n\n• If the -source option is 1.3, then the value of the -target option is 1.4\n\n• If the -source option is 1.5, then the value of the -target option is 1.8\n\n• If the -source option is 1.6, then the value of the -target is option 1.8\n\n• If the -source option is 1.7, then the value of the -target is option 1.8\n\n• For all other values of the -source option, the value of the -target option is the\nvalue of the -source option.\n\n\n-bootclasspath bootclasspath\nCross-compiles against the specified set of boot classes. As with the user class path,\nboot class path entries are separated by colons (:) and can be directories, JAR\narchives, or ZIP archives.\n\nCOMPACT PROFILE OPTION\nBeginning with JDK 8, the javac compiler supports compact profiles. With compact profiles,\napplications that do not require the entire Java platform can be deployed and run with a\nsmaller footprint. The compact profiles feature could be used to shorten the download time\nfor applications from app stores. This feature makes for more compact deployment of Java\napplications that bundle the JRE. This feature is also useful in small devices.\n\nThe supported profile values are compact1, compact2, and compact3. These are additive layers.\nEach higher-numbered compact profile contains all of the APIs in profiles with smaller number\nnames.\n",
                    "flag": "-X"
                },
                {
                    "name": "-profile",
                    "content": "When using compact profiles, this option specifies the profile name when compiling.\nFor example:\n\njavac -profile compact1 Hello.java\n\n\n\njavac does not compile source code that uses any Java SE APIs that is not in the\nspecified profile. Here is an example of the error message that results from\nattempting to compile such source code:\n\ncd jdk1.8.0/bin\n./javac -profile compact1 Paint.java\nPaint.java:5: error: Applet is not available in profile 'compact1'\nimport java.applet.Applet;\n\n\n\nIn this example, you can correct the error by modifying the source to not use the\nApplet class. You could also correct the error by compiling without the -profile\noption. Then the compilation would be run against the full set of Java SE APIs. (None\nof the compact profiles include the Applet class.)\n\nAn alternative way to compile with compact profiles is to use the -bootclasspath\noption to specify a path to an rt.jar file that specifies a profile's image. Using the\n-profile option instead does not require a profile image to be present on the system\nat compile time. This is useful when cross-compiling.\n\nNONSTANDARD OPTIONS\n-Xbootclasspath/p:path\nAdds a suffix to the bootstrap class path.\n\n-Xbootclasspath/a:path\nAdds a prefix to the bootstrap class path.\n\n-Xbootclasspath/:path\nOverrides the location of the bootstrap class files.\n\n-Xdoclint:[-]group [/access]\nEnables or disables specific groups of checks, where group is one of the following\nvalues: accessibility, syntax, reference, html or missing. For more information about\nthese groups of checks see the -Xdoclint option of the javadoc command. The -Xdoclint\noption is disabled by default in the javac command.\n\nThe variable access specifies the minimum visibility level of classes and members that\nthe -Xdoclint option checks. It can have one of the following values (in order of most\nto least visible) : public, protected, package and private. For example, the following\noption checks classes and members (with all groups of checks) that have the access\nlevel protected and higher (which includes protected, package and public):\n\n-Xdoclint:all/protected\n\n\n\nThe following option enables all groups of checks for all access levels, except it\nwill not check for HTML errors for classes and members that have access level package\nand higher (which includes package and public):\n\n-Xdoclint:all,-html/package\n\n\n\n-Xdoclint:none\nDisables all groups of checks.\n\n-Xdoclint:all[/access]\nEnables all groups of checks.\n"
                },
                {
                    "name": "-Xlint",
                    "content": "Enables all recommended warnings. In this release, enabling all available warnings is\nrecommended.\n\n-Xlint:all\nEnables all recommended warnings. In this release, enabling all available warnings is\nrecommended.\n\n-Xlint:none\nDisables all warnings.\n\n-Xlint:name\nDisables warning name. See Enable or Disable Warnings with the -Xlint Option for a\nlist of warnings you can disable with this option.\n\n-Xlint:-name\nDisables warning name. See Enable or Disable Warnings with the -Xlint Option with the\n-Xlint option to get a list of warnings that you can disable with this option.\n\n-Xmaxerrs number\nSets the maximum number of errors to print.\n\n-Xmaxwarns number\nSets the maximum number of warnings to print.\n\n-Xstdout filename\nSends compiler messages to the named file. By default, compiler messages go to\nSystem.err.\n\n-Xprefer:[newer,source]\nSpecifies which file to read when both a source file and class file are found for a\ntype. (See Searching for Types). If the -Xprefer:newer option is used, then it reads\nthe newer of the source or class file for a type (default). If the -Xprefer:source\noption is used, then it reads the source file. Use -Xprefer:source when you want to be\nsure that any annotation processors can access annotations declared with a retention\npolicy of SOURCE.\n\n-Xpkginfo:[always,legacy,nonempty]\nControl whether javac generates package-info.class files from package-info.java files.\nPossible mode arguments for this option include the following.\n\nalways Always generate a package-info.class file for every package-info.java file.\nThis option may be useful if you use a build system such as Ant, which checks\nthat each .java file has a corresponding .class file.\n\nlegacy Generate a package-info.class file only if package-info.java contains\nannotations. Don't generate a package-info.class file if package-info.java only\ncontains comments.\n\nNote: A package-info.class file might be generated but be empty if all the\nannotations in the package-info.java file have RetentionPolicy.SOURCE.\n\nnonempty\nGenerate a package-info.class file only if package-info.java contains\nannotations with RetentionPolicy.CLASS or RetentionPolicy.RUNTIME.\n\n"
                },
                {
                    "name": "-Xprint",
                    "content": "Prints a textual representation of specified types for debugging purposes. Perform\nneither annotation processing nor compilation. The format of the output could change.\n"
                },
                {
                    "name": "-XprintProcessorInfo",
                    "content": "Prints information about which annotations a processor is asked to process.\n"
                },
                {
                    "name": "-XprintRounds",
                    "content": "Prints information about initial and subsequent annotation processing rounds.\n"
                }
            ]
        },
        "ENABLE OR DISABLE WARNINGS WITH THE -XLINT OPTION": {
            "content": "Enable warning name with the -Xlint:name option, where name is one of the following warning\nnames. Note that you can disable a warning with the -Xlint:-name: option.\n\ncast   Warns about unnecessary and redundant casts, for example:\n\nString s = (String) \"Hello!\"\n\n\n\nclassfile\nWarns about issues related to class file contents.\n\ndeprecation\nWarns about the use of deprecated items, for example:\n\njava.util.Date myDate = new java.util.Date();\nint currentDay = myDate.getDay();\n\n\n\nThe method java.util.Date.getDay has been deprecated since JDK 1.1\n\ndep-ann\nWarns about items that are documented with an @deprecated Javadoc comment, but do not\nhave a @Deprecated annotation, for example:\n\n/\n* @deprecated As of Java SE 7, replaced by {@link #newMethod()}\n*/\npublic static void deprecatedMethood() { }\npublic static void newMethod() { }\n\n\n\ndivzero\nWarns about division by the constant integer 0, for example:\n\nint divideByZero = 42 / 0;\n\n\n\nempty  Warns about empty statements after ifstatements, for example:\n\nclass E {\nvoid m() {\nif (true) ;\n}\n}\n\n\n\nfallthrough\nChecks the switch blocks for fall-through cases and provides a warning message for any\nthat are found. Fall-through cases are cases in a switch block, other than the last\ncase in the block, whose code does not include a break statement, allowing code\nexecution to fall through from that case to the next case. For example, the code\nfollowing the case 1 label in this switch block does not end with a break statement:\n\nswitch (x) {\ncase 1:\nSystem.out.println(\"1\");\n// No break statement here.\ncase 2:\nSystem.out.println(\"2\");\n}\n\n\n\nIf the -Xlint:fallthrough option was used when compiling this code, then the compiler\nemits a warning about possible fall-through into case, with the line number of the\ncase in question.\n\nfinally\nWarns about finally clauses that cannot complete normally, for example:\n\npublic static int m() {\ntry {\nthrow new NullPointerException();\n}  catch (NullPointerException(); {\nSystem.err.println(\"Caught NullPointerException.\");\nreturn 1;\n} finally {\nreturn 0;\n}\n}\n\n\n\nThe compiler generates a warning for the finally block in this example. When the int\nmethod is called, it returns a value of 0. A finally block executes when the try block\nexits. In this example, when control is transferred to the catch block, the int method\nexits. However, the finally block must execute, so it is executed, even though control\nwas transferred outside the method.\n\noptions\nWarns about issues that related to the use of command-line options. See Cross-\nCompilation Options.\n\noverrides\nWarns about issues regarding method overrides. For example, consider the following two\nclasses:\n\npublic class ClassWithVarargsMethod {\nvoid varargsMethod(String... s) { }\n}\npublic class ClassWithOverridingMethod extends ClassWithVarargsMethod {\n@Override\nvoid varargsMethod(String[] s) { }\n}\n\n\n\nThe compiler generates a warning similar to the following:.\n\nwarning: [override] varargsMethod(String[]) in ClassWithOverridingMethod\noverrides varargsMethod(String...) in ClassWithVarargsMethod; overriding\nmethod is missing '...'\n\n\n\nWhen the compiler encounters a varargs method, it translates the varargs formal\nparameter into an array. In the method ClassWithVarargsMethod.varargsMethod, the\ncompiler translates the varargs formal parameter String... s to the formal parameter\nString[] s, an array, which matches the formal parameter of the method\nClassWithOverridingMethod.varargsMethod. Consequently, this example compiles.\n\npath   Warns about invalid path elements and nonexistent path directories on the command line\n(with regard to the class path, the source path, and other paths). Such warnings\ncannot be suppressed with the @SuppressWarnings annotation, for example:\n\njavac -Xlint:path -classpath /nonexistentpath Example.java\n\n\n\nprocessing\nWarn about issues regarding annotation processing. The compiler generates this warning\nwhen you have a class that has an annotation, and you use an annotation processor that\ncannot handle that type of exception. For example, the following is a simple\nannotation processor:\n\nSource file AnnocProc.java:\n\nimport java.util.*;\nimport javax.annotation.processing.*;\nimport javax.lang.model.*;\nimport.javaz.lang.model.element.*;\n@SupportedAnnotationTypes(\"NotAnno\")\npublic class AnnoProc extends AbstractProcessor {\npublic boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv){\nreturn true;\n}\npublic SourceVersion getSupportedSourceVersion() {\nreturn SourceVersion.latest();\n}\n}\n\n\n\nSource file AnnosWithoutProcessors.java:\n\n@interface Anno { }\n@Anno\nclass AnnosWithoutProcessors { }\n\n\n\nThe following commands compile the annotation processor AnnoProc, then run this\nannotation processor against the source file AnnosWithoutProcessors.java:\n\njavac AnnoProc.java\njavac -cp . -Xlint:processing -processor AnnoProc -proc:only AnnosWithoutProcessors.java\n\n\n\nWhen the compiler runs the annotation processor against the source file\nAnnosWithoutProcessors.java, it generates the following warning:\n\nwarning: [processing] No processor claimed any of these annotations: Anno\n\n\n\nTo resolve this issue, you can rename the annotation defined and used in the class\nAnnosWithoutProcessors from Anno to NotAnno.\n\nrawtypes\nWarns about unchecked operations on raw types. The following statement generates a\nrawtypes warning:\n\nvoid countElements(List l) { ... }\n\n\n\nThe following example does not generate a rawtypes warning\n\nvoid countElements(List<?> l) { ... }\n\n\n\nList is a raw type. However, List<?> is an unbounded wildcard parameterized type.\nBecause List is a parameterized interface, always specify its type argument. In this\nexample, the List formal argument is specified with an unbounded wildcard (?) as its\nformal type parameter, which means that the countElements method can accept any\ninstantiation of the List interface.\n\nSerial Warns about missing serialVersionUID definitions on serializable classes, for example:\n\npublic class PersistentTime implements Serializable\n{\nprivate Date time;\npublic PersistentTime() {\ntime = Calendar.getInstance().getTime();\n}\npublic Date getTime() {\nreturn time;\n}\n}\n\n\n\nThe compiler generates the following warning:\n\nwarning: [serial] serializable class PersistentTime has no definition of\nserialVersionUID\n\n\n\nIf a serializable class does not explicitly declare a field named serialVersionUID,\nthen the serialization runtime environment calculates a default serialVersionUID value\nfor that class based on various aspects of the class, as described in the Java Object\nSerialization Specification. However, it is strongly recommended that all serializable\nclasses explicitly declare serialVersionUID values because the default process of\ncomputing serialVersionUID vales is highly sensitive to class details that can vary\ndepending on compiler implementations, and as a result, might cause an unexpected\nInvalidClassExceptions during deserialization. To guarantee a consistent\nserialVersionUID value across different Java compiler implementations, a serializable\nclass must declare an explicit serialVersionUID value.\n\nstatic Warns about issues relating to the use of statics, for example:\n\nclass XLintStatic {\nstatic void m1() { }\nvoid m2() { this.m1(); }\n}\n\n\n\nThe compiler generates the following warning:\n\nwarning: [static] static method should be qualified by type name,\nXLintStatic, instead of by an expression\n\n\n\nTo resolve this issue, you can call the static method m1 as follows:\n\nXLintStatic.m1();\n\n\n\nAlternately, you can remove the static keyword from the declaration of the method m1.\n\ntry    Warns about issues relating to use of try blocks, including try-with-resources\nstatements. For example, a warning is generated for the following statement because\nthe resource ac declared in the try block is not used:\n\ntry ( AutoCloseable ac = getResource() ) {    // do nothing}\n\n\n\nunchecked\nGives more detail for unchecked conversion warnings that are mandated by the Java\nLanguage Specification, for example:\n\nList l = new ArrayList<Number>();\nList<String> ls = l;       // unchecked warning\n\n\n\nDuring type erasure, the types ArrayList<Number> and List<String> become ArrayList and\nList, respectively.\n\nThe ls command has the parameterized type List<String>. When the List referenced by l\nis assigned to ls, the compiler generates an unchecked warning. At compile time, the\ncompiler and JVM cannot determine whether l refers to a List<String> type. In this\ncase, l does not refer to a List<String> type. As a result, heap pollution occurs.\n\nA heap pollution situation occurs when the List object l, whose static type is\nList<Number>, is assigned to another List object, ls, that has a different static\ntype, List<String>. However, the compiler still allows this assignment. It must allow\nthis assignment to preserve backward compatibility with releases of Java SE that do\nnot support generics. Because of type erasure, List<Number> and List<String> both\nbecome List. Consequently, the compiler allows the assignment of the object l, which\nhas a raw type of List, to the object ls.\n\nvarargs\nWarns about unsafe usages of variable arguments (varargs) methods, in particular,\nthose that contain non-reifiable arguments, for example:\n\npublic class ArrayBuilder {\npublic static <T> void addToList (List<T> listArg, T... elements) {\nfor (T x : elements) {\nlistArg.add(x);\n}\n}\n}\n\n\n\nNote: A non-reifiable type is a type whose type information is not fully available at\nruntime.\n\nThe compiler generates the following warning for the definition of the method\nArrayBuilder.addToList\n\nwarning: [varargs] Possible heap pollution from parameterized vararg type T\n\n\n\nWhen the compiler encounters a varargs method, it translates the varargs formal\nparameter into an array. However, the Java programming language does not permit the\ncreation of arrays of parameterized types. In the method ArrayBuilder.addToList, the\ncompiler translates the varargs formal parameter T... elements to the formal parameter\nT[] elements, an array. However, because of type erasure, the compiler converts the\nvarargs formal parameter to Object[] elements. Consequently, there is a possibility of\nheap pollution.\n",
            "subsections": []
        },
        "COMMAND-LINE ARGUMENT FILES": {
            "content": "To shorten or simplify the javac command, you can specify one or more files that contain\narguments to the javac command (except -J options). This enables you to create javac commands\nof any length on any operating system.\n\nAn argument file can include javac options and source file names in any combination. The\narguments within a file can be separated by spaces or new line characters. If a file name\ncontains embedded spaces, then put the whole file name in double quotation marks.\n\nFile Names within an argument file are relative to the current directory, not the location of\nthe argument file. Wild cards (*) are not allowed in these lists (such as for specifying\n*.java). Use of the at sign (@) to recursively interpret files is not supported. The -J\noptions are not supported because they are passed to the launcher, which does not support\nargument files.\n\nWhen executing the javac command, pass in the path and name of each argument file with the at\nsign (@) leading character. When the javac command encounters an argument beginning with the\nat sign (@), it expands the contents of that file into the argument list.\n",
            "subsections": [
                {
                    "name": "Example 1 Single Argument File",
                    "content": "You could use a single argument file named argfile to hold all javac arguments:\n"
                },
                {
                    "name": "javac @argfile",
                    "content": "This argument file could contain the contents of both files shown in Example 2\n"
                },
                {
                    "name": "Example 2 Two Argument Files",
                    "content": "You can create two argument files: one for the javac options and the other for the source\nfile names. Note that the following lists have no line-continuation characters.\n\nCreate a file named options that contains the following:\n"
                },
                {
                    "name": "-d classes",
                    "content": "",
                    "flag": "-d"
                },
                {
                    "name": "-g",
                    "content": "",
                    "flag": "-g"
                },
                {
                    "name": "-sourcepath /java/pubs/ws/1.3/src/share/classes",
                    "content": "Create a file named classes that contains the following:\n"
                },
                {
                    "name": "MyClass1.java",
                    "content": ""
                },
                {
                    "name": "MyClass2.java",
                    "content": ""
                },
                {
                    "name": "MyClass3.java",
                    "content": "Then, run the javac command as follows:\n"
                },
                {
                    "name": "javac @options @classes",
                    "content": ""
                },
                {
                    "name": "Example 3 Argument Files with Paths",
                    "content": "The argument files can have paths, but any file names inside the files are relative to the\ncurrent working directory (not path1 or path2):\n"
                },
                {
                    "name": "javac @path1/options @path2/classes",
                    "content": ""
                }
            ]
        },
        "ANNOTATION PROCESSING": {
            "content": "The javac command provides direct support for annotation processing, superseding the need for\nthe separate annotation processing command, apt.\n\nThe API for annotation processors is defined in the javax.annotation.processing and\njavax.lang.model packages and subpackages.\n\nHOW ANNOTATION PROCESSING WORKS\nUnless annotation processing is disabled with the -proc:none option, the compiler searches\nfor any annotation processors that are available. The search path can be specified with the",
            "subsections": [
                {
                    "name": "-processorpath",
                    "content": "are located by means of service provider-configuration files named META-\nINF/services/javax.annotation.processing.Processor on the search path. Such files should\ncontain the names of any annotation processors to be used, listed one per line.\nAlternatively, processors can be specified explicitly, using the -processor option.\n\nAfter scanning the source files and classes on the command line to determine what annotations\nare present, the compiler queries the processors to determine what annotations they process.\nWhen a match is found, the processor is called. A processor can claim the annotations it\nprocesses, in which case no further attempt is made to find any processors for those\nannotations. After all of the annotations are claimed, the compiler does not search for\nadditional processors.\n\nIf any processors generate new source files, then another round of annotation processing\noccurs: Any newly generated source files are scanned, and the annotations processed as\nbefore. Any processors called on previous rounds are also called on all subsequent rounds.\nThis continues until no new source files are generated.\n\nAfter a round occurs where no new source files are generated, the annotation processors are\ncalled one last time, to give them a chance to complete any remaining work. Finally, unless\nthe -proc:only option is used, the compiler compiles the original and all generated source\nfiles.\n\nIMPLICITLY LOADED SOURCE FILES\nTo compile a set of source files, the compiler might need to implicitly load additional\nsource files. See Searching for Types. Such files are currently not subject to annotation\nprocessing. By default, the compiler gives a warning when annotation processing occurred and\nany implicitly loaded source files are compiled. The -implicit option provides a way to\nsuppress the warning.\n"
                }
            ]
        },
        "SEARCHING FOR TYPES": {
            "content": "To compile a source file, the compiler often needs information about a type, but the type\ndefinition is not in the source files specified on the command line. The compiler needs type\ninformation for every class or interface used, extended, or implemented in the source file.\nThis includes classes and interfaces not explicitly mentioned in the source file, but that\nprovide information through inheritance.\n\nFor example, when you create a subclass java.applet.Applet, you are also using the ancestor\nclasses of Applet: java.awt.Panel, java.awt.Container, java.awt.Component, and\njava.lang.Object.\n\nWhen the compiler needs type information, it searches for a source file or class file that\ndefines the type. The compiler searches for class files first in the bootstrap and extension\nclasses, then in the user class path (which by default is the current directory). The user\nclass path is defined by setting the CLASSPATH environment variable or by using the",
            "subsections": [
                {
                    "name": "-classpath",
                    "content": "If you set the -sourcepath option, then the compiler searches the indicated path for source\nfiles. Otherwise, the compiler searches the user class path for both class files and source\nfiles.\n\nYou can specify different bootstrap or extension classes with the -bootclasspath and the"
                },
                {
                    "name": "-extdirs",
                    "content": "A successful type search may produce a class file, a source file, or both. If both are found,\nthen you can use the -Xprefer option to instruct the compiler which to use. If newer is\nspecified, then the compiler uses the newer of the two files. If source is specified, the\ncompiler uses the source file. The default is newer.\n\nIf a type search finds a source file for a required type, either by itself, or as a result of\nthe setting for the -Xprefer option, then the compiler reads the source file to get the\ninformation it needs. By default the compiler also compiles the source file. You can use the"
                },
                {
                    "name": "-implicit",
                    "content": "generated for the source file. If class is specified, then class files are generated for the\nsource file.\n\nThe compiler might not discover the need for some type information until after annotation\nprocessing completes. When the type information is found in a source file and no -implicit\noption is specified, the compiler gives a warning that the file is being compiled without\nbeing subject to annotation processing. To disable the warning, either specify the file on\nthe command line (so that it will be subject to annotation processing) or use the -implicit\noption to specify whether or not class files should be generated for such source files.\n"
                }
            ]
        },
        "PROGRAMMATIC INTERFACE": {
            "content": "The javac command supports the new Java Compiler API defined by the classes and interfaces in\nthe javax.tools package.\n\nEXAMPLE\nTo compile as though providing command-line arguments, use the following syntax:\n",
            "subsections": [
                {
                    "name": "JavaCompiler javac = ToolProvider.getSystemJavaCompiler();",
                    "content": "The example writes diagnostics to the standard output stream and returns the exit code that\njavac would give when called from the command line.\n\nYou can use other methods in the javax.tools.JavaCompiler interface to handle diagnostics,\ncontrol where files are read from and written to, and more.\n\nOLD INTERFACE\nNote: This API is retained for backward compatibility only. All new code should use the newer\nJava Compiler API.\n\nThe com.sun.tools.javac.Main class provides two static methods to call the compiler from a\nprogram:\n"
                },
                {
                    "name": "public static int compile(String[] args);",
                    "content": ""
                },
                {
                    "name": "public static int compile(String[] args, PrintWriter out);",
                    "content": "The args parameter represents any of the command-line arguments that would typically be\npassed to the compiler.\n\nThe out parameter indicates where the compiler diagnostic output is directed.\n\nThe return value is equivalent to the exit value from javac.\n\nNote: All other classes and methods found in a package with names that start with\ncom.sun.tools.javac (subpackages of com.sun.tools.javac) are strictly internal and subject to\nchange at any time.\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "Example 1 Compile a Simple Program",
                    "content": "This example shows how to compile the Hello.java source file in the greetings directory. The\nclass defined in Hello.java is called greetings.Hello. The greetings directory is the package\ndirectory both for the source file and the class file and is underneath the current\ndirectory. This makes it possible to use the default user class path. It also makes it\nunnecessary to specify a separate destination directory with the -d option.\n\nThe source code in Hello.java:\n"
                },
                {
                    "name": "package greetings;",
                    "content": ""
                },
                {
                    "name": "public class Hello {",
                    "content": "public static void main(String[] args) {\nfor (int i=0; i < args.length; i++) {\nSystem.out.println(\"Hello \" + args[i]);\n}\n}\n}\n\nCompile greetings.Hello:\n"
                },
                {
                    "name": "javac greetings/Hello.java",
                    "content": "Run greetings.Hello:\n"
                },
                {
                    "name": "java greetings.Hello World Universe Everyone",
                    "content": ""
                },
                {
                    "name": "Hello World",
                    "content": ""
                },
                {
                    "name": "Hello Universe",
                    "content": ""
                },
                {
                    "name": "Hello Everyone",
                    "content": ""
                },
                {
                    "name": "Example 2 Compile Multiple Source Files",
                    "content": "This example compiles the Aloha.java, GutenTag.java, Hello.java, and Hi.java source files in\nthe greetings package.\n\n% javac greetings/*.java"
                },
                {
                    "name": "% ls greetings",
                    "content": ""
                },
                {
                    "name": "Aloha.class         GutenTag.class      Hello.class         Hi.class",
                    "content": ""
                },
                {
                    "name": "Aloha.java          GutenTag.java       Hello.java          Hi.java",
                    "content": ""
                },
                {
                    "name": "Example 3 Specify a User Class Path",
                    "content": "After changing one of the source files in the previous example, recompile it:\n"
                },
                {
                    "name": "pwd",
                    "content": ""
                },
                {
                    "name": "/examples",
                    "content": ""
                },
                {
                    "name": "javac greetings/Hi.java",
                    "content": "Because greetings.Hi refers to other classes in the greetings package, the compiler needs to\nfind these other classes. The previous example works because the default user class path is\nthe directory that contains the package directory. If you want to recompile this file without\nconcern for which directory you are in, then add the examples directory to the user class\npath by setting CLASSPATH. This example uses the -classpath option.\n"
                },
                {
                    "name": "javac -classpath /examples /examples/greetings/Hi.java",
                    "content": "If you change greetings.Hi to use a banner utility, then that utility also needs to be\naccessible through the user class path.\n"
                },
                {
                    "name": "javac -classpath /examples:/lib/Banners.jar \\",
                    "content": "/examples/greetings/Hi.java\n\nTo execute a class in the greetings package, the program needs access to the greetings\npackage, and to the classes that the greetings classes use.\n"
                },
                {
                    "name": "java -classpath /examples:/lib/Banners.jar greetings.Hi",
                    "content": ""
                },
                {
                    "name": "Example 4 Separate Source Files and Class Files",
                    "content": "The following example uses javac to compile code that runs on JVM 1.7.\n"
                },
                {
                    "name": "javac -source 1.7 -target 1.7 -bootclasspath jdk1.7.0/lib/rt.jar \\",
                    "content": ""
                },
                {
                    "name": "-extdirs \"\" OldCode.java",
                    "content": "The -source 1.7 option specifies that release 1.7 (or 7) of the Java programming language be\nused to compile OldCode.java. The option -target 1.7 option ensures that the generated class\nfiles are compatible with JVM 1.7. Note that in most cases, the value of the -target option\nis the value of the -source option; in this example, you can omit the -target option.\n\nYou must specify the -bootclasspath option to specify the correct version of the bootstrap\nclasses (the rt.jar library). If not, then the compiler generates a warning:\n"
                },
                {
                    "name": "javac -source 1.7 OldCode.java",
                    "content": ""
                },
                {
                    "name": "warning: [options] bootstrap class path not set in conjunction with",
                    "content": ""
                },
                {
                    "name": "-source 1.7",
                    "content": "If you do not specify the correct version of bootstrap classes, then the compiler uses the\nold language rules (in this example, it uses version 1.7 of the Java programming language)\ncombined with the new bootstrap classes, which can result in class files that do not work on\nthe older platform (in this case, Java SE 7) because reference to nonexistent methods can get\nincluded.\n"
                },
                {
                    "name": "Example 5 Cross Compile",
                    "content": "This example uses javac to compile code that runs on JVM 1.7.\n"
                },
                {
                    "name": "javac -source 1.7 -target 1.7 -bootclasspath jdk1.7.0/lib/rt.jar \\",
                    "content": "-extdirs \"\" OldCode.java\n\nThe-source 1.7 option specifies that release 1.7 (or 7) of the Java programming language to\nbe used to compile OldCode.java. The -target 1.7 option ensures that the generated class\nfiles are compatible with JVM 1.7.\n\nYou must specify the -bootclasspath option to specify the correct version of the bootstrap\nclasses (the rt.jar library). If not, then the compiler generates a warning:\n"
                },
                {
                    "name": "javac -source 1.7 OldCode.java",
                    "content": ""
                },
                {
                    "name": "warning: [options] bootstrap class path not set in conjunction with -source 1.7",
                    "content": "If you do not specify the correct version of bootstrap classes, then the compiler uses the\nold language rules combined with the new bootstrap classes. This combination can result in\nclass files that do not work on the older platform (in this case, Java SE 7) because\nreference to nonexistent methods can get included. In this example, the compiler uses release\n1.7 of the Java programming language.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "• java(1)\n\n• jdb(1)\n\n• javah(1)\n\n• javadoc(1)\n\n• jar(1)\n\n• jdb(1)\n\n\n\nJDK 8                                       03 March 2015                                   javac(1)",
            "subsections": []
        }
    },
    "summary": "javac - Reads Java class and interface definitions and compiles them into bytecode and class files.",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Specifies options to pass to annotation processors. These options are not interpreted by javac directly, but are made available for use by individual processors. The key value should be one or more identifiers separated by a dot (.). -cp path or -classpath path Specifies where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in the CLASSPATH environment variable. If neither CLASSPATH, -cp nor -classpath is specified, then the user class path is the current directory. See Setting the Class Path. If the -sourcepath option is not specified, then the user class path is also searched for source files. If the -processorpath option is not specified, then the class path is also searched for annotation processors. -Djava.ext.dirs=directories Overrides the location of installed extensions. -Djava.endorsed.dirs=directories Overrides the location of the endorsed standards path. -d directory Sets the destination directory for class files. The directory must already exist because javac does not create it. If a class is part of a package, then javac puts the class file in a subdirectory that reflects the package name and creates directories as needed. If you specify -d/home/myclasses and the class is called com.mypackage.MyClass, then the class file is /home/myclasses/com/mypackage/MyClass.class. If the -d option is not specified, then javac puts each class file in the same directory as the source file from which it was generated. Note: The directory specified by the -d option is not automatically added to your user class path."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Shows a description of each use or override of a deprecated member or class. Without the -deprecation option, javac shows a summary of the source files that use or override deprecated members or classes. The -deprecation option is shorthand for -Xlint:deprecation. -encoding encoding Sets the source file encoding name, such as EUC-JP and UTF-8. If the -encoding option is not specified, then the platform default converter is used. -endorseddirs directories Overrides the location of the endorsed standards path. -extdirs directories Overrides the location of the ext directory. The directories variable is a colon- separated list of directories. Each JAR file in the specified directories is searched for class files. All JAR files found become part of the class path. If you are cross-compiling (compiling classes against bootstrap and extension classes of a different Java platform implementation), then this option specifies the directories that contain the extension classes. See Cross-Compilation Options for more information."
        },
        {
            "flag": "-g",
            "long": null,
            "arg": null,
            "description": "Generates all debugging information, including local variables. By default, only line number and source file information is generated. -g:none Does not generate any debugging information. -g:[keyword list] Generates only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are: source Source file debugging information. lines Line number debugging information. vars Local variable debugging information."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints a synopsis of standard options. -implicit:[class, none] Controls the generation of class files for implicitly loaded source files. To automatically generate class files, use -implicit:class. To suppress class file generation, use -implicit:none. If this option is not specified, then the default is to automatically generate class files. In this case, the compiler issues a warning if any such class files are generated when also doing annotation processing. The warning is not issued when the -implicit option is set explicitly. See Searching for Types."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Passes option to the Java Virtual Machine (JVM), where option is one of the options described on the reference page for the Java launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1). Note: The CLASSPATH, -classpath, -bootclasspath, and -extdirs options do not specify the classes used to run javac. Trying to customize the compiler implementation with these options and variables is risky and often does not accomplish what you want. If you must customize the complier implementation, then use the -J option to pass options through to the underlying Java launcher."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Disables warning messages. This option operates the same as the -Xlint:none option."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Stores formal parameter names of constructors and methods in the generated class file so that the method java.lang.reflect.Executable.getParameters from the Reflection API can retrieve them. -proc: [none, only] Controls whether annotation processing and compilation are done. -proc:none means that compilation takes place without annotation processing. -proc:only means that only annotation processing is done, without any subsequent compilation. -processor class1 [,class2,class3...] Names of the annotation processors to run. This bypasses the default discovery process. -processorpath path Specifies where to find annotation processors. If this option is not used, then the class path is searched for processors. -s dir Specifies the directory where to place the generated source files. The directory must already exist because javac does not create it. If a class is part of a package, then the compiler puts the source file in a subdirectory that reflects the package name and creates directories as needed. If you specify -s /home/mysrc and the class is called com.mypackage.MyClass, then the source file is put in /home/mysrc/com/mypackage/MyClass.java. -source release Specifies the version of source code accepted. The following values for release are allowed: 1.3 The compiler does not support assertions, generics, or other language features introduced after Java SE 1.3. 1.4 The compiler accepts code containing assertions, which were introduced in Java SE 1.4. 1.5 The compiler accepts code containing generics and other language features introduced in Java SE 5. 5 Synonym for 1.5. 1.6 No language changes were introduced in Java SE 6. However, encoding errors in source files are now reported as errors instead of warnings as in earlier releases of Java Platform, Standard Edition. 6 Synonym for 1.6. 1.7 The compiler accepts code with features introduced in Java SE 7. 7 Synonym for 1.7. 1.8 This is the default value. The compiler accepts code with features introduced in Java SE 8. 8 Synonym for 1.8. -sourcepath sourcepath Specifies the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by colons (:) on Oracle Solaris and semicolons on Windows and can be directories, JAR archives, or ZIP archives. If packages are used, then the local path name within the directory or archive must reflect the package name. Note: Classes found through the class path might be recompiled when their source files are also found. See Searching for Types."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Uses verbose output, which includes information about each class loaded and each source file compiled."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints release information."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Terminates compilation when warnings occur."
        },
        {
            "flag": "-X",
            "long": null,
            "arg": null,
            "description": "Displays information about nonstandard options and exits. CROSS-COMPILATION OPTIONS By default, classes are compiled against the bootstrap and extension classes of the platform that javac shipped with. But javac also supports cross-compiling, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation. It is important to use the -bootclasspath and -extdirs options when cross-compiling. -target version Generates class files that target a specified release of the virtual machine. Class files will run on the specified target and on later releases, but not on earlier releases of the JVM. Valid targets are 1.1, 1.2, 1.3, 1.4, 1.5 (also 5), 1.6 (also 6), 1.7 (also 7), and 1.8 (also 8). The default for the -target option depends on the value of the -source option: • If the -source option is not specified, then the value of the -target option is 1.8 • If the -source option is 1.2, then the value of the -target option is 1.4 • If the -source option is 1.3, then the value of the -target option is 1.4 • If the -source option is 1.5, then the value of the -target option is 1.8 • If the -source option is 1.6, then the value of the -target is option 1.8 • If the -source option is 1.7, then the value of the -target is option 1.8 • For all other values of the -source option, the value of the -target option is the value of the -source option. -bootclasspath bootclasspath Cross-compiles against the specified set of boot classes. As with the user class path, boot class path entries are separated by colons (:) and can be directories, JAR archives, or ZIP archives. COMPACT PROFILE OPTION Beginning with JDK 8, the javac compiler supports compact profiles. With compact profiles, applications that do not require the entire Java platform can be deployed and run with a smaller footprint. The compact profiles feature could be used to shorten the download time for applications from app stores. This feature makes for more compact deployment of Java applications that bundle the JRE. This feature is also useful in small devices. The supported profile values are compact1, compact2, and compact3. These are additive layers. Each higher-numbered compact profile contains all of the APIs in profiles with smaller number names."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "When using compact profiles, this option specifies the profile name when compiling. For example: javac -profile compact1 Hello.java javac does not compile source code that uses any Java SE APIs that is not in the specified profile. Here is an example of the error message that results from attempting to compile such source code: cd jdk1.8.0/bin ./javac -profile compact1 Paint.java Paint.java:5: error: Applet is not available in profile 'compact1' import java.applet.Applet; In this example, you can correct the error by modifying the source to not use the Applet class. You could also correct the error by compiling without the -profile option. Then the compilation would be run against the full set of Java SE APIs. (None of the compact profiles include the Applet class.) An alternative way to compile with compact profiles is to use the -bootclasspath option to specify a path to an rt.jar file that specifies a profile's image. Using the -profile option instead does not require a profile image to be present on the system at compile time. This is useful when cross-compiling. NONSTANDARD OPTIONS -Xbootclasspath/p:path Adds a suffix to the bootstrap class path. -Xbootclasspath/a:path Adds a prefix to the bootstrap class path. -Xbootclasspath/:path Overrides the location of the bootstrap class files. -Xdoclint:[-]group [/access] Enables or disables specific groups of checks, where group is one of the following values: accessibility, syntax, reference, html or missing. For more information about these groups of checks see the -Xdoclint option of the javadoc command. The -Xdoclint option is disabled by default in the javac command. The variable access specifies the minimum visibility level of classes and members that the -Xdoclint option checks. It can have one of the following values (in order of most to least visible) : public, protected, package and private. For example, the following option checks classes and members (with all groups of checks) that have the access level protected and higher (which includes protected, package and public): -Xdoclint:all/protected The following option enables all groups of checks for all access levels, except it will not check for HTML errors for classes and members that have access level package and higher (which includes package and public): -Xdoclint:all,-html/package -Xdoclint:none Disables all groups of checks. -Xdoclint:all[/access] Enables all groups of checks."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Enables all recommended warnings. In this release, enabling all available warnings is recommended. -Xlint:all Enables all recommended warnings. In this release, enabling all available warnings is recommended. -Xlint:none Disables all warnings. -Xlint:name Disables warning name. See Enable or Disable Warnings with the -Xlint Option for a list of warnings you can disable with this option. -Xlint:-name Disables warning name. See Enable or Disable Warnings with the -Xlint Option with the -Xlint option to get a list of warnings that you can disable with this option. -Xmaxerrs number Sets the maximum number of errors to print. -Xmaxwarns number Sets the maximum number of warnings to print. -Xstdout filename Sends compiler messages to the named file. By default, compiler messages go to System.err. -Xprefer:[newer,source] Specifies which file to read when both a source file and class file are found for a type. (See Searching for Types). If the -Xprefer:newer option is used, then it reads the newer of the source or class file for a type (default). If the -Xprefer:source option is used, then it reads the source file. Use -Xprefer:source when you want to be sure that any annotation processors can access annotations declared with a retention policy of SOURCE. -Xpkginfo:[always,legacy,nonempty] Control whether javac generates package-info.class files from package-info.java files. Possible mode arguments for this option include the following. always Always generate a package-info.class file for every package-info.java file. This option may be useful if you use a build system such as Ant, which checks that each .java file has a corresponding .class file. legacy Generate a package-info.class file only if package-info.java contains annotations. Don't generate a package-info.class file if package-info.java only contains comments. Note: A package-info.class file might be generated but be empty if all the annotations in the package-info.java file have RetentionPolicy.SOURCE. nonempty Generate a package-info.class file only if package-info.java contains annotations with RetentionPolicy.CLASS or RetentionPolicy.RUNTIME."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints a textual representation of specified types for debugging purposes. Perform neither annotation processing nor compilation. The format of the output could change."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints information about which annotations a processor is asked to process."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints information about initial and subsequent annotation processing rounds."
        }
    ],
    "examples": [
        "This example shows how to compile the Hello.java source file in the greetings directory. The",
        "class defined in Hello.java is called greetings.Hello. The greetings directory is the package",
        "directory both for the source file and the class file and is underneath the current",
        "directory. This makes it possible to use the default user class path. It also makes it",
        "unnecessary to specify a separate destination directory with the -d option.",
        "The source code in Hello.java:",
        "public static void main(String[] args) {",
        "for (int i=0; i < args.length; i++) {",
        "System.out.println(\"Hello \" + args[i]);",
        "Compile greetings.Hello:",
        "Run greetings.Hello:",
        "This example compiles the Aloha.java, GutenTag.java, Hello.java, and Hi.java source files in",
        "the greetings package.",
        "% javac greetings/*.java",
        "After changing one of the source files in the previous example, recompile it:",
        "Because greetings.Hi refers to other classes in the greetings package, the compiler needs to",
        "find these other classes. The previous example works because the default user class path is",
        "the directory that contains the package directory. If you want to recompile this file without",
        "concern for which directory you are in, then add the examples directory to the user class",
        "path by setting CLASSPATH. This example uses the -classpath option.",
        "If you change greetings.Hi to use a banner utility, then that utility also needs to be",
        "accessible through the user class path.",
        "/examples/greetings/Hi.java",
        "To execute a class in the greetings package, the program needs access to the greetings",
        "package, and to the classes that the greetings classes use.",
        "The following example uses javac to compile code that runs on JVM 1.7.",
        "The -source 1.7 option specifies that release 1.7 (or 7) of the Java programming language be",
        "used to compile OldCode.java. The option -target 1.7 option ensures that the generated class",
        "files are compatible with JVM 1.7. Note that in most cases, the value of the -target option",
        "is the value of the -source option; in this example, you can omit the -target option.",
        "You must specify the -bootclasspath option to specify the correct version of the bootstrap",
        "classes (the rt.jar library). If not, then the compiler generates a warning:",
        "If you do not specify the correct version of bootstrap classes, then the compiler uses the",
        "old language rules (in this example, it uses version 1.7 of the Java programming language)",
        "combined with the new bootstrap classes, which can result in class files that do not work on",
        "the older platform (in this case, Java SE 7) because reference to nonexistent methods can get",
        "included.",
        "This example uses javac to compile code that runs on JVM 1.7.",
        "-extdirs \"\" OldCode.java",
        "The-source 1.7 option specifies that release 1.7 (or 7) of the Java programming language to",
        "be used to compile OldCode.java. The -target 1.7 option ensures that the generated class",
        "files are compatible with JVM 1.7.",
        "You must specify the -bootclasspath option to specify the correct version of the bootstrap",
        "classes (the rt.jar library). If not, then the compiler generates a warning:",
        "If you do not specify the correct version of bootstrap classes, then the compiler uses the",
        "old language rules combined with the new bootstrap classes. This combination can result in",
        "class files that do not work on the older platform (in this case, Java SE 7) because",
        "reference to nonexistent methods can get included. In this example, the compiler uses release",
        "1.7 of the Java programming language."
    ],
    "see_also": [
        {
            "name": "java",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/java/1/json"
        },
        {
            "name": "jdb",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/jdb/1/json"
        },
        {
            "name": "javah",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/javah/1/json"
        },
        {
            "name": "javadoc",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/javadoc/1/json"
        },
        {
            "name": "jar",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/jar/1/json"
        },
        {
            "name": "jdb",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/jdb/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Java application compiler.",
        "examples": [
            {
                "description": "Compile a `.java` file",
                "command": "javac {{path/to/file.java}}"
            },
            {
                "description": "Compile several `.java` files",
                "command": "javac {{path/to/file1.java path/to/file2.java ...}}"
            },
            {
                "description": "Compile all `.java` files in current directory",
                "command": "javac {{*.java}}"
            },
            {
                "description": "Compile a `.java` file and place the resulting class file in a specific directory",
                "command": "javac -d {{path/to/directory}} {{path/to/file.java}}"
            }
        ]
    }
}