Bookmark this site!


ant javac Xlint:unchecked

You are porting your code to Java 5.0 (aka 1.5); building your project under Xcode gives the following notes from javac:

[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
This raises the following question:
Q: How do I pass -Xlint:unchecked to an ant javac task?
A: Edit the relevant target in your build.xml file to add an embedded compilerarg entry, to the javac task:
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint"/>
so it reads something like this:
<target name="compile" description="Compile code">
       <mkdir dir="${bin}"/>
       <mkdir dir="${lib}"/>
       <javac srcdir="${src}" destdir="${bin}" 
           <compilerarg value="-Xlint"/>
Using "-Xlint" enables all recommended Xlint options, including :unchecked. See the Sun javac documentation (scroll down to Xlint) for details of other options, giving finer control if you need it.


Minge said...

This blog is a godsend.

Subir S said...

Really useful blog...

I was just searching for that option...

Asmya said...

so, javac uses 1.5 by default if we have both 1.5 and 1.4 is it?

My question is, what if I want to say javac -source 1.5?

Anonymous said...

Köszi a segítséget!

Jeremy Stein said...


Valerio Schiavoni said...

thanks !

Anonymous said...


Anonymous said...

This is not a Mac OS tip, but a java developer tip, thanks.