How to add -Xlint:unchecked option or any javac option in Eclipse?

后端 未结 4 541
挽巷
挽巷 2021-01-25 16:48

How can i to add -Xlint:unchecked option or any javac option in Eclipse? this is strange there is no obvious way to do that in eclipse.

Thanks in advance

相关标签:
4条回答
  • 2021-01-25 17:12

    If you are doing builds with ant in Eclipse (as I was today), then it's really not a setting in Eclipse but an additional setting/flag(?) on the javac task.

    Found via Darins' helpful hint here:

    Specifically compilerarg nested element.

    Here's how to add it, found on the Apache javac task page

    <javac srcdir="${src.dir}"
         destdir="${classes.dir}"
         classpathref="libraries">
       <compilerarg value="-Xlint"/>
    </javac> 
    

    Hope this helps someone else, as I didn't quite get it at first myself.

    0 讨论(0)
  • 2021-01-25 17:18

    First, go to the Preferences window. If you're running Windows or Linux, it'll be under the 'Window' menu, if you're using Mac OSX it'll be under the 'Eclipse' menu. Then go to Java -> Compiler -> Errors / Warnings -> Generic Types and you'll see three options for compiler warnings / errors on unchecked types and operations. Chang them from error or warning to ignore.

    0 讨论(0)
  • 2021-01-25 17:21

    Eclipse does not use the javac compiler - it has its own compiler.

    0 讨论(0)
  • 2021-01-25 17:28

    -Xlint:unchecked is set to warning by default in eclipse

    0 讨论(0)
提交回复
热议问题