Index

Compiler Warnings


We want to resolve all compiler warnings. The compiler is telling us that we may have problems when we run our code. And "run-time" issues are far worse then "compile-time" issues (because our users find them).

If our code has warning level messages, and we are compiling without showing warnings, we should get messages similar to these:

Note: Foo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.



Use the flag shown to tell the compiler to display warnings.
>javac -Xlint:unchecked -classpath "." Foo.java



Supressing Warnings


Usually we resolve warnings by making appropriate changes to our code. However, we may encounter cases where we determine that our code is okay and we want to suppress the warning. The Java compiler allows us to do that.

Find more information here:


Classpath Tips


An example of placing jar files on the classpath
>javac -classpath ".;geometry.jar" Foo.java
>javac -classpath ".;lib1\a.jar;lib2\b.jar" Moo.java



classpath space separator gotcha


Do NOT space separator between classpaths

This fails:

java -cp "jars\common.jar; jars\app.jar" com.app.Sample1


The problem is the space after the semicolon -- it can cause problems.

jars\common.jar; jars\app.jar


The fix is removing the space