How can i to add -Xlint:unchecked option or any javac option in Eclipse? this is strange there is no obvious way to 开发者_如何学JAVAdo that in eclipse.
Thanks in advance
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.
Eclipse does not use the javac compiler - it has its own compiler.
-Xlint:unchecked is set to warning by default in eclipse
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.
精彩评论