When you use the -classpath command line argument, you have to specify that foo must be in the classpath : javac -classpath /tomcat/common/lib/servlet-api.jar;. BeerSelect.java or in Unix: javac -classpath /tomcat/common/lib/servlet-api.jar:. BeerSelect.java