Search code examples
javacompiler-errorsunchecked

How do I compile with -Xlint:unchecked?


I'm getting a message when I compile my code:

Note: H:\Project2\MyGui2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

How do I recompile with -Xlint:unchecked?


Solution

  • Specify it on the command line for javac:

    javac -Xlint:unchecked

    Or if you are using Ant modify your javac target

      <javac ...>
        <compilerarg value="-Xlint"/>
      </javac> 
    

    If you are using Maven, configure this in the maven-compiler-plugin

    <compilerArgument>-Xlint:unchecked</compilerArgument>